Mercurial > hg-stable
annotate mercurial/debugcommands.py @ 36557:72e487851a53
debugcommands: add debugwireproto command
We currently don't have a low-level mechanism for sending
arbitrary wire protocol commands. Having a generic and robust
mechanism for sending wire protocol commands, examining wire
data, etc would make it vastly easier to test the wire protocol
and debug server operation. This is a problem I've wanted a
solution for numerous times, especially recently as I've been
hacking on a new version of the wire protocol.
This commit establishes a `hg debugwireproto` command for sending
data to a peer.
The command invents a mini language for specifying actions to take.
This will enable a lot of flexibility for issuing commands and testing
variations for how commands are sent.
Right now, we only support low-level raw sends and receives. These
are probably the least valuable commands to intended users of this
command. But they are the most useful commands to implement to
bootstrap the feature (I've chosen to reimplement test-ssh-proto.t
using this command to prove its usefulness).
My eventual goal of `hg debugwireproto` is to allow calling wire
protocol commands with a human-friendly interface. Essentially,
people can type in a command name and arguments and
`hg debugwireproto` will figure out how to send that on the wire.
I'd love to eventually be able to save the server's raw response
to a file. This would allow us to e.g. call "getbundle" wire
protocol commands easily.
test-ssh-proto.t has been updated to use the new command in lieu
of piping directly to a server process. As part of the transition,
test behavior improved. Before, we piped all request data to the
server at once. Now, we have explicit control over the ordering of
operations. e.g. we can send one command, receive its response,
then send another command. This will allow us to more robustly
test race conditions, buffering behavior, etc.
There were some subtle changes in test behavior. For example,
previous behavior would often send trailing newlines to the server.
The new mechanism doesn't treat literal newlines specially and
requires newlines be escaped in the payload.
Because the new logging code is very low level, it is easy to
introduce race conditions in tests. For example, the number of bytes
returned by a read() may vary depending on load. This is why tests
make heavy use of "readline" for consuming data: the result of
that operation should be deterministic and not subject to race
conditions. There are still some uses of "readavailable." However,
those are only for reading from stderr. I was able to reproduce
timing issues with my system under load when using "readavailable"
globally. But if I "readline" to grab stdout, "readavailable"
appears to work deterministically for stderr. I think this is
because the server writes to stderr first. As long as the OS
delivers writes to pipes in the same order they were made, this
should work. If there are timing issues, we can introduce a
mechanism to readline from stderr.
Differential Revision: https://phab.mercurial-scm.org/D2392
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 01 Mar 2018 08:24:54 -0800 |
parents | 44dc34b8d17b |
children | bde0bd50f368 |
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 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com> |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
34144
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34135
diff
changeset
|
10 import codecs |
34043
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
11 import collections |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
12 import difflib |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
13 import errno |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
14 import operator |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
15 import os |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
16 import random |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
17 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
|
18 import ssl |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
19 import string |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
20 import subprocess |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
21 import sys |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
22 import tempfile |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
23 import time |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 from .i18n import _ |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
26 from .node import ( |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
27 bin, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
28 hex, |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
29 nullhex, |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
30 nullid, |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
31 nullrev, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
32 short, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
33 ) |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 from . import ( |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
35 bundle2, |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
36 changegroup, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 cmdutil, |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
38 color, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
39 context, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
40 dagparser, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
41 dagutil, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
42 encoding, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 error, |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
44 exchange, |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
45 extensions, |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
46 filemerge, |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
47 fileset, |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
48 formatter, |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
49 hg, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
50 localrepo, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
51 lock as lockmod, |
35928
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
52 logcmdutil, |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
53 merge as mergemod, |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
54 obsolete, |
33148
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33119
diff
changeset
|
55 obsutil, |
32765
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
56 phases, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
57 policy, |
30967
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
58 pvec, |
30528
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30527
diff
changeset
|
59 pycompat, |
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32355
diff
changeset
|
60 registrar, |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
61 repair, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 revlog, |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
63 revset, |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
64 revsetlang, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 scmutil, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
66 setdiscovery, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
67 simplemerge, |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
68 smartset, |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
69 sshpeer, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
70 sslutil, |
30511
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30510
diff
changeset
|
71 streamclone, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
72 templater, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
73 treediscovery, |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31694
diff
changeset
|
74 upgrade, |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
75 url as urlmod, |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
76 util, |
31249
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31226
diff
changeset
|
77 vfs as vfsmod, |
36556
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
78 wireprotoserver, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 ) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
81 release = lockmod.release |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
82 |
32416
c942c83ac2ec
debugcommands: use temporary dict for its command table
Yuya Nishihara <yuya@tcha.org>
parents:
32415
diff
changeset
|
83 command = registrar.command() |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 def debugancestor(ui, repo, *args): |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 """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
|
88 if len(args) == 3: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 index, rev1, rev2 = args |
31249
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31226
diff
changeset
|
90 r = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), index) |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 lookup = r.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 elif len(args) == 2: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 if not repo: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 raise error.Abort(_('there is no Mercurial repository here ' |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 '(.hg not found)')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 rev1, rev2 = args |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 r = repo.changelog |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 lookup = repo.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 else: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 raise error.Abort(_('either two or three arguments required')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 a = r.ancestor(lookup(rev1), lookup(rev2)) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 ui.write('%d:%s\n' % (r.rev(a), hex(a))) |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
103 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
104 @command('debugapplystreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
105 def debugapplystreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
106 """apply a stream clone bundle file""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
107 f = hg.openpath(ui, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
108 gen = exchange.readbundle(ui, f, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
109 gen.apply(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
110 |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
111 @command('debugbuilddag', |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
112 [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
113 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
114 ('n', 'new-file', None, _('add new file at each rev'))], |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
115 _('[OPTION]... [TEXT]')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
116 def debugbuilddag(ui, repo, text=None, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
117 mergeable_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
118 overwritten_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
119 new_file=False): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
120 """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
|
121 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
122 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
|
123 command line. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
124 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
125 Elements: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
126 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
127 - "+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
|
128 - "." is a single node based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
129 - "$" resets the default parent to null (implied at the start); |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
130 otherwise the default parent is always the last node created |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
131 - "<p" sets the default parent to the backref p |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
132 - "*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
|
133 - "*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
|
134 - "/p2" is a merge of the preceding node and p2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
135 - ":tag" defines a local tag for the preceding node |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
136 - "@branch" sets the named branch for subsequent nodes |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
137 - "#...\\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
|
138 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
139 Whitespace between the above elements is ignored. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
140 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
141 A backref is either |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
142 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
143 - 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
|
144 node, or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
145 - 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
|
146 - empty to denote the default parent. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
147 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
148 All string valued-elements are either strictly alphanumeric, or must |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
149 be enclosed in double quotes ("..."), with "\\" as escape character. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
150 """ |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
151 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
152 if text is None: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
153 ui.status(_("reading DAG from stdin\n")) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
154 text = ui.fin.read() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
155 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
156 cl = repo.changelog |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
157 if len(cl) > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
158 raise error.Abort(_('repository is not empty')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
159 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
160 # determine number of revs in DAG |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
161 total = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
162 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
163 if type == 'n': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
164 total += 1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
165 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
166 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
167 linesperrev = 2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
168 # make a file with k lines per rev |
36351
3f67c56a5fd7
debugbuilddag: use '%d' instead of str() to get numbered lines
Augie Fackler <augie@google.com>
parents:
36342
diff
changeset
|
169 initialmergedlines = ['%d' % i for i in xrange(0, total * linesperrev)] |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
170 initialmergedlines.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
171 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
172 tags = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
173 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
174 wlock = lock = tr = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
175 try: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
176 wlock = repo.wlock() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
177 lock = repo.lock() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
178 tr = repo.transaction("builddag") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
179 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
180 at = -1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
181 atbranch = 'default' |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
182 nodeids = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
183 id = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
184 ui.progress(_('building'), id, unit=_('revisions'), total=total) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
185 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
186 if type == 'n': |
35585
35fb3367f72d
py3: use pycompat.bytestr() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35562
diff
changeset
|
187 ui.note(('node %s\n' % pycompat.bytestr(data))) |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
188 id, ps = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
189 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
190 files = [] |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
191 filecontent = {} |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
192 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
193 p2 = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
194 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
195 fn = "mf" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
196 p1 = repo[ps[0]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
197 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
198 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
199 pa = p1.ancestor(p2) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
200 base, local, other = [x[fn].data() for x in (pa, p1, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
201 p2)] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
202 m3 = simplemerge.Merge3Text(base, local, other) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
203 ml = [l.strip() for l in m3.merge_lines()] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
204 ml.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
205 elif at > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
206 ml = p1[fn].data().split("\n") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
207 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
208 ml = initialmergedlines |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
209 ml[id * linesperrev] += " r%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
210 mergedtext = "\n".join(ml) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
211 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
212 filecontent[fn] = mergedtext |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
213 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
214 if overwritten_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
215 fn = "of" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
216 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
217 filecontent[fn] = "r%i\n" % id |
30412
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 if new_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
220 fn = "nf%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
221 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
222 filecontent[fn] = "r%i\n" % id |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
223 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
224 if not p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
225 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
226 for fn in p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
227 if fn.startswith("nf"): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
228 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
229 filecontent[fn] = p2[fn].data() |
30412
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 def fctxfn(repo, cx, path): |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
232 if path in filecontent: |
35407
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35406
diff
changeset
|
233 return context.memfilectx(repo, cx, path, |
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35406
diff
changeset
|
234 filecontent[path]) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
235 return None |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
236 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
237 if len(ps) == 0 or ps[0] < 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
238 pars = [None, None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
239 elif len(ps) == 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
240 pars = [nodeids[ps[0]], None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
241 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
242 pars = [nodeids[p] for p in ps] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
243 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
244 date=(id, 0), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
245 user="debugbuilddag", |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
246 extra={'branch': atbranch}) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
247 nodeid = repo.commitctx(cx) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
248 nodeids.append(nodeid) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
249 at = id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
250 elif type == 'l': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
251 id, name = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
252 ui.note(('tag %s\n' % name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
253 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
254 elif type == 'a': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
255 ui.note(('branch %s\n' % data)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
256 atbranch = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
257 ui.progress(_('building'), id, unit=_('revisions'), total=total) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
258 tr.close() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
259 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
260 if tags: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
261 repo.vfs.write("localtags", "".join(tags)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
262 finally: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
263 ui.progress(_('building'), None) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
264 release(tr, lock, wlock) |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
265 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
266 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
267 indent_string = ' ' * indent |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
268 if all: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
269 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
270 % indent_string) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
271 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
272 def showchunks(named): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
273 ui.write("\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
|
274 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
275 node, p1, p2, cs, deltabase, delta, flags = deltadata |
36489
580f75f70f39
py3: use '%d' to convert integers to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36445
diff
changeset
|
276 ui.write("%s%s %s %s %s %s %d\n" % |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
277 (indent_string, hex(node), hex(p1), hex(p2), |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
278 hex(cs), hex(deltabase), len(delta))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
279 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
280 chunkdata = gen.changelogheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
281 showchunks("changelog") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
282 chunkdata = gen.manifestheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
283 showchunks("manifest") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
284 for chunkdata in iter(gen.filelogheader, {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
285 fname = chunkdata['filename'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
286 showchunks(fname) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
287 else: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
288 if isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
289 raise error.Abort(_('use debugbundle2 for this file')) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
290 chunkdata = gen.changelogheader() |
34299
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
291 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
292 node, p1, p2, cs, deltabase, delta, flags = deltadata |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
293 ui.write("%s%s\n" % (indent_string, hex(node))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
294 |
33041
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
295 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
|
296 """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
|
297 opts = pycompat.byteskwargs(opts) |
33041
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
298 data = part.read() |
32550
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
299 indent_string = ' ' * indent |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
300 try: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
301 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
|
302 except error.UnknownVersion as exc: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
303 msg = "%sunsupported version: %s (%d bytes)\n" |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
304 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
|
305 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
306 else: |
35165
8f6641fa7c89
py3: use '%d' for integers rather than '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35082
diff
changeset
|
307 msg = "%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
|
308 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
|
309 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
310 fm = ui.formatter('debugobsolete', opts) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
311 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
|
312 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
|
313 fm.startitem() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
314 fm.plain(indent_string) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
315 cmdutil.showmarker(fm, m) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
316 fm.end() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
317 |
33043
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
318 def _debugphaseheads(ui, data, indent=0): |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
319 """display version and markers contained in 'data'""" |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
320 indent_string = ' ' * indent |
34327
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34299
diff
changeset
|
321 headsbyphase = phases.binarydecode(data) |
33043
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
322 for phase in phases.allphases: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
323 for head in headsbyphase[phase]: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
324 ui.write(indent_string) |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
325 ui.write('%s %s\n' % (hex(head), phases.phasenames[phase])) |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
326 |
34043
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
327 def _quasirepr(thing): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
328 if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
329 return '{%s}' % ( |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
330 b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing))) |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
331 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
|
332 |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
333 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
|
334 """lists the contents of a bundle2""" |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
335 if not isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
336 raise error.Abort(_('not a bundle2 file')) |
34043
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
337 ui.write(('Stream params: %s\n' % _quasirepr(gen.params))) |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
338 parttypes = opts.get(r'part_type', []) |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
339 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
|
340 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
|
341 continue |
34043
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
342 ui.write('%s -- %s\n' % (part.type, _quasirepr(part.params))) |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
343 if part.type == 'changegroup': |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
344 version = part.params.get('version', '01') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
345 cg = changegroup.getunbundler(version, part, 'UN') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
346 _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
32550
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
347 if part.type == 'obsmarkers': |
33041
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
348 _debugobsmarkers(ui, part, indent=4, **opts) |
33043
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
349 if part.type == 'phase-heads': |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
350 _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
|
351 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
352 @command('debugbundle', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
353 [('a', 'all', None, _('show all details')), |
32714
3ef319e9505f
debugbundle: add --part-type flag to emit only named part types
Danek Duvall <danek.duvall@oracle.com>
parents:
32649
diff
changeset
|
354 ('', 'part-type', [], _('show only the named part type')), |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
355 ('', 'spec', None, _('print the bundlespec of the bundle'))], |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
356 _('FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
357 norepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
358 def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
359 """lists the contents of a bundle""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
360 with hg.openpath(ui, bundlepath) as f: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
361 if spec: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
362 spec = exchange.getbundlespec(ui, f) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
363 ui.write('%s\n' % spec) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
364 return |
30511
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30510
diff
changeset
|
365 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
366 gen = exchange.readbundle(ui, f, bundlepath) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
367 if isinstance(gen, bundle2.unbundle20): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
368 return _debugbundle2(ui, gen, all=all, **opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
369 _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
|
370 |
35015
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
371 @command('debugcapabilities', |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
372 [], _('PATH'), |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
373 norepo=True) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
374 def debugcapabilities(ui, path, **opts): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
375 """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
|
376 opts = pycompat.byteskwargs(opts) |
35015
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
377 peer = hg.peer(ui, opts, path) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
378 caps = peer.capabilities() |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
379 ui.write(('Main capabilities:\n')) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
380 for c in sorted(caps): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
381 ui.write((' %s\n') % c) |
35016
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
382 b2caps = bundle2.bundle2caps(peer) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
383 if b2caps: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
384 ui.write(('Bundle2 capabilities:\n')) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
385 for key, values in sorted(b2caps.iteritems()): |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
386 ui.write((' %s\n') % key) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
387 for v in values: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
388 ui.write((' %s\n') % v) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
389 |
30512
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
390 @command('debugcheckstate', [], '') |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
391 def debugcheckstate(ui, repo): |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
392 """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
|
393 parent1, parent2 = repo.dirstate.parents() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
394 m1 = repo[parent1].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
395 m2 = repo[parent2].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
396 errors = 0 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
397 for f in repo.dirstate: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
398 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
399 if state in "nr" and f not in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
400 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
401 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
402 if state in "a" and f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
403 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
404 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
405 if state in "m" and f not in m1 and f not in m2: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
406 ui.warn(_("%s in state %s, but not in either manifest\n") % |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
407 (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
408 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
409 for f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
410 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
411 if state not in "nrm": |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
412 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
413 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
414 if errors: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
415 error = _(".hg/dirstate inconsistent with current parent's manifest") |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
416 raise error.Abort(error) |
30513
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30512
diff
changeset
|
417 |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
418 @command('debugcolor', |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
419 [('', 'style', None, _('show all configured styles'))], |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
420 'hg debugcolor') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
421 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
|
422 """show available color, effects or style""" |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
423 ui.write(('color mode: %s\n') % ui._colormode) |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
424 if opts.get(r'style'): |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
425 return _debugdisplaystyle(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
426 else: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
427 return _debugdisplaycolor(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
428 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
429 def _debugdisplaycolor(ui): |
31136
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
430 ui = ui.copy() |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
431 ui._styles.clear() |
31694
57a22f699179
color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents:
31639
diff
changeset
|
432 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
|
433 ui._styles[effect] = effect |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
434 if ui._terminfoparams: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
435 for k, v in ui.configitems('color'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
436 if k.startswith('color.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
437 ui._styles[k] = k[6:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
438 elif k.startswith('terminfo.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
439 ui._styles[k] = k[9:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
440 ui.write(_('available colors:\n')) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
441 # sort label with a '_' after the other to group '_background' entry. |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
442 items = sorted(ui._styles.items(), |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
443 key=lambda i: ('_' in i[0], i[0], i[1])) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
444 for colorname, label in items: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
445 ui.write(('%s\n') % colorname, label=label) |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
446 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
447 def _debugdisplaystyle(ui): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
448 ui.write(_('available style:\n')) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
449 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
|
450 for label, effects in sorted(ui._styles.items()): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
451 ui.write('%s' % label, label=label) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
452 if effects: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
453 # 50 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
454 ui.write(': ') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
455 ui.write(' ' * (max(0, width - len(label)))) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
456 ui.write(', '.join(ui.label(e, e) for e in effects.split())) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
457 ui.write('\n') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
458 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
459 @command('debugcreatestreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
460 def debugcreatestreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
461 """create a stream clone bundle file |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
462 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
463 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
|
464 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
|
465 """ |
32765
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
466 # 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
|
467 # 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
|
468 if phases.hassecret(repo): |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
469 ui.warn(_('(warning: stream clone bundle will contain secret ' |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
470 'revisions)\n')) |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
471 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
472 requirements, gen = streamclone.generatebundlev1(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
473 changegroup.writechunks(ui, gen, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
474 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
475 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
476 |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
477 @command('debugdag', |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
478 [('t', 'tags', None, _('use tags as labels')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
479 ('b', 'branches', None, _('annotate with branch names')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
480 ('', 'dots', None, _('use dots for runs')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
481 ('s', 'spaces', None, _('separate elements by spaces'))], |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
482 _('[OPTION]... [FILE [REV]...]'), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
483 optionalrepo=True) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
484 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
|
485 """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
|
486 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
487 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
|
488 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
|
489 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
490 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
|
491 """ |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
492 spaces = opts.get(r'spaces') |
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
493 dots = opts.get(r'dots') |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
494 if file_: |
31249
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31226
diff
changeset
|
495 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), |
30528
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30527
diff
changeset
|
496 file_) |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
497 revs = set((int(r) for r in revs)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
498 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
499 for r in rlog: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
500 yield 'n', (r, list(p for p in rlog.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
501 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
502 if r in revs: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
503 yield 'l', (r, "r%i" % r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
504 elif repo: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
505 cl = repo.changelog |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
506 tags = opts.get(r'tags') |
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
507 branches = opts.get(r'branches') |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
508 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
509 labels = {} |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
510 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
|
511 labels.setdefault(cl.rev(n), []).append(l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
512 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
513 b = "default" |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
514 for r in cl: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
515 if branches: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
516 newb = cl.read(cl.node(r))[5]['branch'] |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
517 if newb != b: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
518 yield 'a', newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
519 b = newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
520 yield 'n', (r, list(p for p in cl.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
521 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
522 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
523 ls = labels.get(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
524 if ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
525 for l in ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
526 yield 'l', (r, l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
527 else: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
528 raise error.Abort(_('need repo for changelog dag')) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
529 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
530 for line in dagparser.dagtextlines(events(), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
531 addspaces=spaces, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
532 wraplabels=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
533 wrapannotations=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
534 wrapnonlinear=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
535 usedots=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
536 maxlinewidth=70): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
537 ui.write(line) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
538 ui.write("\n") |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
539 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
540 @command('debugdata', cmdutil.debugrevlogopts, _('-c|-m|FILE REV')) |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
541 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
|
542 """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
|
543 opts = pycompat.byteskwargs(opts) |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
544 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
545 if rev is not None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
546 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
547 file_, rev = None, file_ |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
548 elif rev is None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
549 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
550 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
551 try: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30550
diff
changeset
|
552 ui.write(r.revision(r.lookup(rev), raw=True)) |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
553 except KeyError: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
554 raise error.Abort(_('invalid revision identifier %s') % rev) |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
555 |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
556 @command('debugdate', |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
557 [('e', 'extended', None, _('try extended date formats'))], |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
558 _('[-e] DATE [RANGE]'), |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
559 norepo=True, optionalrepo=True) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
560 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
|
561 """parse and display a date""" |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
562 if opts[r"extended"]: |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
563 d = util.parsedate(date, util.extendeddateformats) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
564 else: |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
565 d = util.parsedate(date) |
36429
a24c57f1f5c3
py3: use '%d' for integers instead of '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36368
diff
changeset
|
566 ui.write(("internal: %d %d\n") % d) |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
567 ui.write(("standard: %s\n") % util.datestr(d)) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
568 if range: |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
569 m = util.matchdate(range) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
570 ui.write(("match: %s\n") % m(d[0])) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
571 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
572 @command('debugdeltachain', |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
573 cmdutil.debugrevlogopts + cmdutil.formatteropts, |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
574 _('-c|-m|FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
575 optionalrepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
576 def debugdeltachain(ui, repo, file_=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
577 """dump information about delta chains in a revlog |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
578 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
579 Output can be templatized. Available template keywords are: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
580 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
581 :``rev``: revision number |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
582 :``chainid``: delta chain identifier (numbered by unique base) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
583 :``chainlen``: delta chain length to this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
584 :``prevrev``: previous revision in delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
585 :``deltatype``: role of delta / how it was computed |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
586 :``compsize``: compressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
587 :``uncompsize``: uncompressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
588 :``chainsize``: total size of compressed revisions in chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
589 :``chainratio``: total chain size divided by uncompressed revision size |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
590 (new delta chains typically start at ratio 2.00) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
591 :``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
|
592 of this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
593 :``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
|
594 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
|
595 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
|
596 the delta chain for this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
597 :``extraratio``: extradist divided by chainsize; another representation of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
598 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
|
599 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
600 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
|
601 are available: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
602 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
603 :``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
|
604 (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
|
605 :``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
|
606 :``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
|
607 :``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
|
608 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
609 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
|
610 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
611 opts = pycompat.byteskwargs(opts) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
612 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
613 index = r.index |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
614 generaldelta = r.version & revlog.FLAG_GENERALDELTA |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
615 withsparseread = getattr(r, '_withsparseread', False) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
616 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
617 def revinfo(rev): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
618 e = index[rev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
619 compsize = e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
620 uncompsize = e[2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
621 chainsize = 0 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
622 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
623 if generaldelta: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
624 if e[3] == e[5]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
625 deltatype = 'p1' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
626 elif e[3] == e[6]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
627 deltatype = 'p2' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
628 elif e[3] == rev - 1: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
629 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
630 elif e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
631 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
632 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
633 deltatype = 'other' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
634 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
635 if e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
636 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
637 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
638 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
639 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
640 chain = r._deltachain(rev)[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
641 for iterrev in chain: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
642 e = index[iterrev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
643 chainsize += e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
644 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
645 return compsize, uncompsize, deltatype, chain, chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
646 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
647 fm = ui.formatter('debugdeltachain', opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
648 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
649 fm.plain(' rev chain# chainlen prev delta ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
650 'size rawsize chainsize ratio lindist extradist ' |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
651 'extraratio') |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
652 if withsparseread: |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
653 fm.plain(' readsize largestblk rddensity srchunks') |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
654 fm.plain('\n') |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
655 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
656 chainbases = {} |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
657 for rev in r: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
658 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
659 chainbase = chain[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
660 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
|
661 start = r.start |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
662 length = r.length |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
663 basestart = start(chainbase) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
664 revstart = start(rev) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
665 lineardist = revstart + comp - basestart |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
666 extradist = lineardist - chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
667 try: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
668 prevrev = chain[-2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
669 except IndexError: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
670 prevrev = -1 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
671 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
672 chainratio = float(chainsize) / float(uncomp) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
673 extraratio = float(extradist) / float(chainsize) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
674 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
675 fm.startitem() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
676 fm.write('rev chainid chainlen prevrev deltatype compsize ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
677 'uncompsize chainsize chainratio lindist extradist ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
678 'extraratio', |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
679 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f', |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
680 rev, chainid, len(chain), prevrev, deltatype, comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
681 uncomp, chainsize, chainratio, lineardist, extradist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
682 extraratio, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
683 rev=rev, chainid=chainid, chainlen=len(chain), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
684 prevrev=prevrev, deltatype=deltatype, compsize=comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
685 uncompsize=uncomp, chainsize=chainsize, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
686 chainratio=chainratio, lindist=lineardist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
687 extradist=extradist, extraratio=extraratio) |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
688 if withsparseread: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
689 readsize = 0 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
690 largestblock = 0 |
35728
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
691 srchunks = 0 |
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
692 |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
693 for revschunk in revlog._slicechunk(r, chain): |
35728
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
694 srchunks += 1 |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
695 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
|
696 blksize = blkend - start(revschunk[0]) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
697 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
698 readsize += blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
699 if largestblock < blksize: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
700 largestblock = blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
701 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
702 readdensity = float(chainsize) / float(readsize) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
703 |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
704 fm.write('readsize largestblock readdensity srchunks', |
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
705 ' %10d %10d %9.5f %8d', |
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
706 readsize, largestblock, readdensity, srchunks, |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
707 readsize=readsize, largestblock=largestblock, |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
708 readdensity=readdensity, srchunks=srchunks) |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
709 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
710 fm.plain('\n') |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
711 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
712 fm.end() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
713 |
30974
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
714 @command('debugdirstate|debugstate', |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
715 [('', 'nodates', None, _('do not display the saved mtime')), |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
716 ('', 'datesort', None, _('sort by saved mtime'))], |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
717 _('[OPTION]...')) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
718 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
|
719 """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
|
720 |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
721 nodates = opts.get(r'nodates') |
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
722 datesort = opts.get(r'datesort') |
30974
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
723 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
724 timestr = "" |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
725 if datesort: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
726 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
727 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
728 keyfunc = None # sort by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
729 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
730 if ent[3] == -1: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
731 timestr = 'unset ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
732 elif nodates: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
733 timestr = 'set ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
734 else: |
35172
b45a9d121b53
py3: make sure the first argument of time.strftime() is str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35165
diff
changeset
|
735 timestr = time.strftime(r"%Y-%m-%d %H:%M:%S ", |
30974
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
736 time.localtime(ent[3])) |
35214
d4b108fdf423
py3: use encoding.strtolocal() to convert string to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35172
diff
changeset
|
737 timestr = encoding.strtolocal(timestr) |
30974
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
738 if ent[1] & 0o20000: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
739 mode = 'lnk' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
740 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
741 mode = '%3o' % (ent[1] & 0o777 & ~util.umask) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
742 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
743 for f in repo.dirstate.copies(): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
744 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
745 |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
746 @command('debugdiscovery', |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
747 [('', 'old', None, _('use old-style discovery')), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
748 ('', 'nonheads', None, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
749 _('use old-style discovery with non-heads included')), |
35313
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
750 ('', 'rev', [], 'restrict discovery to this set of revs'), |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
751 ] + cmdutil.remoteopts, |
35431
702e6d2642e7
debugdiscovery: correct and clean up command synopsis
Martin von Zweigbergk <martinvonz@google.com>
parents:
35426
diff
changeset
|
752 _('[--rev REV] [OTHER]')) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
753 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
754 """runs the changeset discovery protocol in isolation""" |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
755 opts = pycompat.byteskwargs(opts) |
35424
2105bdd9462a
debugdiscovery: drop reference to invalid --branch option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35408
diff
changeset
|
756 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl)) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
757 remote = hg.peer(repo, opts, remoteurl) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
758 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
759 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
760 # make sure tests are repeatable |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
761 random.seed(12323) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
762 |
35313
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
763 def doit(pushedrevs, remoteheads, remote=remote): |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
764 if opts.get('old'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
765 if not util.safehasattr(remote, 'branches'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
766 # enable in-client legacy support |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
767 remote = localrepo.locallegacypeer(remote.local()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
768 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
769 force=True) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
770 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
771 if not opts.get('nonheads'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
772 ui.write(("unpruned common: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
773 " ".join(sorted(short(n) for n in common))) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
774 dag = dagutil.revlogdag(repo.changelog) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
775 all = dag.ancestorset(dag.internalizeall(common)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
776 common = dag.externalizeall(dag.headsetofconnecteds(all)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
777 else: |
35313
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
778 nodes = None |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
779 if pushedrevs: |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
780 revs = scmutil.revrange(repo, pushedrevs) |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
781 nodes = [repo[r].node() for r in revs] |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
782 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote, |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
783 ancestorsof=nodes) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
784 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
785 rheads = set(hds) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
786 lheads = set(repo.heads()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
787 ui.write(("common heads: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
788 " ".join(sorted(short(n) for n in common))) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
789 if lheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
790 ui.write(("local is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
791 elif rheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
792 ui.write(("remote is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
793 |
35426
fed2c040764e
debugdiscovery: drop reference to non-existent --remote-head option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35425
diff
changeset
|
794 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
35425
c73d23cbb129
debugdiscovery: drop reference to non-existent --serverlog option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35424
diff
changeset
|
795 localrevs = opts['rev'] |
c73d23cbb129
debugdiscovery: drop reference to non-existent --serverlog option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35424
diff
changeset
|
796 doit(localrevs, remoterevs) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
797 |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
798 _chunksize = 4 << 10 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
799 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
800 @command('debugdownload', |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
801 [ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
802 ('o', 'output', '', _('path')), |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
803 ], |
35730
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
804 optionalrepo=True) |
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
805 def debugdownload(ui, repo, url, output=None, **opts): |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
806 """download a resource using Mercurial logic and config |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
807 """ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
808 fh = urlmod.open(ui, url, output) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
809 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
810 dest = ui |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
811 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
812 dest = open(output, "wb", _chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
813 try: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
814 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
815 while data: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
816 dest.write(data) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
817 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
818 finally: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
819 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
820 dest.close() |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
821 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
822 @command('debugextensions', cmdutil.formatteropts, [], norepo=True) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
823 def debugextensions(ui, **opts): |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
824 '''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
|
825 opts = pycompat.byteskwargs(opts) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
826 exts = extensions.extensions(ui) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
827 hgver = util.version() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
828 fm = ui.formatter('debugextensions', opts) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
829 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
|
830 isinternal = extensions.ismoduleinternal(extmod) |
31091
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31044
diff
changeset
|
831 extsource = pycompat.fsencode(extmod.__file__) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
832 if isinternal: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
833 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
|
834 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
835 exttestedwith = getattr(extmod, 'testedwith', '').split() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
836 extbuglink = getattr(extmod, 'buglink', None) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
837 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
838 fm.startitem() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
839 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
840 if ui.quiet or ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
841 fm.write('name', '%s\n', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
842 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
843 fm.write('name', '%s', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
844 if isinternal or hgver in exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
845 fm.plain('\n') |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
846 elif not exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
847 fm.plain(_(' (untested!)\n')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
848 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
849 lasttestedversion = exttestedwith[-1] |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
850 fm.plain(' (%s!)\n' % lasttestedversion) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
851 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
852 fm.condwrite(ui.verbose and extsource, 'source', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
853 _(' location: %s\n'), extsource or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
854 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
855 if ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
856 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
857 fm.data(bundled=isinternal) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
858 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
859 fm.condwrite(ui.verbose and exttestedwith, 'testedwith', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
860 _(' tested with: %s\n'), |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
861 fm.formatlist(exttestedwith, name='ver')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
862 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
863 fm.condwrite(ui.verbose and extbuglink, 'buglink', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
864 _(' bug reporting: %s\n'), extbuglink or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
865 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
866 fm.end() |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
867 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
868 @command('debugfileset', |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
869 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
870 _('[-r REV] FILESPEC')) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
871 def debugfileset(ui, repo, expr, **opts): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
872 '''parse and apply a fileset specification''' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
873 ctx = scmutil.revsingle(repo, opts.get(r'rev'), None) |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
874 if ui.verbose: |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
875 tree = fileset.parse(expr) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
876 ui.note(fileset.prettyformat(tree), "\n") |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
877 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
878 for f in ctx.getfileset(expr): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
879 ui.write("%s\n" % f) |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
880 |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
881 @command('debugformat', |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
882 [] + cmdutil.formatteropts, |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
883 _('')) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
884 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
|
885 """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
|
886 |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
887 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
|
888 Mercurial default.""" |
35408
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35407
diff
changeset
|
889 opts = pycompat.byteskwargs(opts) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
890 maxvariantlength = max(len(fv.name) for fv in upgrade.allformatvariant) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
891 maxvariantlength = max(len('format-variant'), maxvariantlength) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
892 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
893 def makeformatname(name): |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
894 return '%s:' + (' ' * (maxvariantlength - len(name))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
895 |
35387
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
896 fm = ui.formatter('debugformat', opts) |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
897 if fm.isplain(): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
898 def formatvalue(value): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
899 if util.safehasattr(value, 'startswith'): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
900 return value |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
901 if value: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
902 return 'yes' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
903 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
904 return 'no' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
905 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
906 formatvalue = pycompat.identity |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
907 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
908 fm.plain('format-variant') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
909 fm.plain(' ' * (maxvariantlength - len('format-variant'))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
910 fm.plain(' repo') |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
911 if ui.verbose: |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
912 fm.plain(' config default') |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
913 fm.plain('\n') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
914 for fv in upgrade.allformatvariant: |
35386
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35348
diff
changeset
|
915 fm.startitem() |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
916 repovalue = fv.fromrepo(repo) |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
917 configvalue = fv.fromconfig(repo) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
918 |
35347
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
919 if repovalue != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
920 namelabel = 'formatvariant.name.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
921 repolabel = 'formatvariant.repo.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
922 elif repovalue != fv.default: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
923 namelabel = 'formatvariant.name.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
924 repolabel = 'formatvariant.repo.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
925 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
926 namelabel = 'formatvariant.name.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
927 repolabel = 'formatvariant.repo.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
928 |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
929 fm.write('name', makeformatname(fv.name), fv.name, |
35347
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
930 label=namelabel) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
931 fm.write('repo', ' %3s', formatvalue(repovalue), |
35347
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
932 label=repolabel) |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
933 if fv.default != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
934 configlabel = 'formatvariant.config.special' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
935 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
936 configlabel = 'formatvariant.config.default' |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
937 fm.condwrite(ui.verbose, 'config', ' %6s', formatvalue(configvalue), |
35347
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
938 label=configlabel) |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
939 fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default), |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
940 label='formatvariant.default') |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
941 fm.plain('\n') |
35386
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35348
diff
changeset
|
942 fm.end() |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
943 |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
944 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
945 def debugfsinfo(ui, path="."): |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
946 """show information detected about current filesystem""" |
35518
5880318624c9
debugfs: display the tested path and mount point of the filesystem, if known
Matt Harbison <matt_harbison@yahoo.com>
parents:
35473
diff
changeset
|
947 ui.write(('path: %s\n') % path) |
5880318624c9
debugfs: display the tested path and mount point of the filesystem, if known
Matt Harbison <matt_harbison@yahoo.com>
parents:
35473
diff
changeset
|
948 ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)')) |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
949 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
31638
5b3d55a6821f
debugfsinfo: show fstype for given path
Jun Wu <quark@fb.com>
parents:
31600
diff
changeset
|
950 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
951 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
952 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
31639
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
953 casesensitive = '(unknown)' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
954 try: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
955 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
956 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
957 except OSError: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
958 pass |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
959 ui.write(('case-sensitive: %s\n') % casesensitive) |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
960 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
961 @command('debuggetbundle', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
962 [('H', 'head', [], _('id of head node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
963 ('C', 'common', [], _('id of common node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
964 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
965 _('REPO FILE [-H|-C ID]...'), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
966 norepo=True) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
967 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
|
968 """retrieves a bundle from a repo |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
969 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
970 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
|
971 given file. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
972 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
973 opts = pycompat.byteskwargs(opts) |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
974 repo = hg.peer(ui, opts, repopath) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
975 if not repo.capable('getbundle'): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
976 raise error.Abort("getbundle() not supported by target repository") |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
977 args = {} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
978 if common: |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
979 args[r'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
|
980 if head: |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
981 args[r'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
|
982 # TODO: get desired bundlecaps from command line. |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
983 args[r'bundlecaps'] = None |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
984 bundle = repo.getbundle('debug', **args) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
985 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
986 bundletype = opts.get('type', 'bzip2').lower() |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
987 btypes = {'none': 'HG10UN', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
988 'bzip2': 'HG10BZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
989 'gzip': 'HG10GZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
990 'bundle2': 'HG20'} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
991 bundletype = btypes.get(bundletype) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
992 if bundletype not in bundle2.bundletypes: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
993 raise error.Abort(_('unknown bundle type specified with --type')) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
994 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
|
995 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
996 @command('debugignore', [], '[FILE]') |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
997 def debugignore(ui, repo, *files, **opts): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
998 """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
|
999 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1000 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
|
1001 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1002 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
|
1003 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
|
1004 """ |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1005 ignore = repo.dirstate._ignore |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1006 if not files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1007 # Show all the patterns |
32444
952017471f93
match: implement __repr__() and update users (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32416
diff
changeset
|
1008 ui.write("%s\n" % repr(ignore)) |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1009 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1010 m = scmutil.match(repo[None], pats=files) |
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1011 for f in m.files(): |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1012 nf = util.normpath(f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1013 ignored = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1014 ignoredata = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1015 if nf != '.': |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1016 if ignore(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1017 ignored = nf |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1018 ignoredata = repo.dirstate._ignorefileandline(nf) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1019 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1020 for p in util.finddirs(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1021 if ignore(p): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1022 ignored = p |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1023 ignoredata = repo.dirstate._ignorefileandline(p) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1024 break |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1025 if ignored: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1026 if ignored == nf: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1027 ui.write(_("%s is ignored\n") % m.uipath(f)) |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1028 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1029 ui.write(_("%s is ignored because of " |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1030 "containing folder %s\n") |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1031 % (m.uipath(f), ignored)) |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1032 ignorefile, lineno, line = ignoredata |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1033 ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1034 % (ignorefile, lineno, line)) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1035 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1036 ui.write(_("%s is not ignored\n") % m.uipath(f)) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1037 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1038 @command('debugindex', cmdutil.debugrevlogopts + |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1039 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1040 _('[-f FORMAT] -c|-m|FILE'), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1041 optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1042 def debugindex(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
|
1043 """dump the contents of an index file""" |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1044 opts = pycompat.byteskwargs(opts) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1045 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1046 format = opts.get('format', 0) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1047 if format not in (0, 1): |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1048 raise error.Abort(_("unknown format %d") % format) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1049 |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
1050 generaldelta = r.version & revlog.FLAG_GENERALDELTA |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1051 if generaldelta: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1052 basehdr = ' delta' |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1053 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1054 basehdr = ' base' |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1055 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1056 if ui.debugflag: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1057 shortfn = hex |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1058 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1059 shortfn = short |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1060 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1061 # There might not be anything in r, so have a sane default |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1062 idlen = 12 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1063 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1064 idlen = len(shortfn(r.node(i))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1065 break |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1066 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1067 if format == 0: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1068 ui.write((" rev offset length " + basehdr + " linkrev" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1069 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1070 elif format == 1: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1071 ui.write((" rev flag offset length" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1072 " size " + basehdr + " link p1 p2" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1073 " %s\n") % "nodeid".rjust(idlen)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1074 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1075 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1076 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1077 if generaldelta: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1078 base = r.deltaparent(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1079 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1080 base = r.chainbase(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1081 if format == 0: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1082 try: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1083 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1084 except Exception: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1085 pp = [nullid, nullid] |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1086 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1087 i, r.start(i), r.length(i), base, r.linkrev(i), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1088 shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1089 elif format == 1: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1090 pr = r.parentrevs(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1091 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1092 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1093 base, r.linkrev(i), pr[0], pr[1], shortfn(node))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1094 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1095 @command('debugindexdot', cmdutil.debugrevlogopts, |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1096 _('-c|-m|FILE'), optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1097 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
|
1098 """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
|
1099 opts = pycompat.byteskwargs(opts) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1100 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1101 ui.write(("digraph G {\n")) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1102 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1103 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1104 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1105 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1106 if pp[1] != nullid: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1107 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1108 ui.write("}\n") |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
1109 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1110 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1111 def debuginstall(ui, **opts): |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1112 '''test Mercurial installation |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1113 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1114 Returns 0 on success. |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1115 ''' |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1116 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
|
1117 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1118 def writetemp(contents): |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1119 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
31008
d194f0dba7ac
py3: convert the mode argument of os.fdopen to unicodes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30979
diff
changeset
|
1120 f = os.fdopen(fd, pycompat.sysstr("wb")) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1121 f.write(contents) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1122 f.close() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1123 return name |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1124 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1125 problems = 0 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1126 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1127 fm = ui.formatter('debuginstall', opts) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1128 fm.startitem() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1129 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1130 # encoding |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1131 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1132 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1133 try: |
34144
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34135
diff
changeset
|
1134 codecs.lookup(pycompat.sysstr(encoding.encoding)) |
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34135
diff
changeset
|
1135 except LookupError as inst: |
34145
ada8a19672ab
debuginstall: do not pass exception object to formatter (issue5676)
Yuya Nishihara <yuya@tcha.org>
parents:
34144
diff
changeset
|
1136 err = util.forcebytestr(inst) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1137 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1138 fm.condwrite(err, 'encodingerror', _(" %s\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1139 " (check that your locale is properly set)\n"), err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1140 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1141 # Python |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1142 fm.write('pythonexe', _("checking Python executable (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1143 pycompat.sysexecutable) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1144 fm.write('pythonver', _("checking Python version (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1145 ("%d.%d.%d" % sys.version_info[:3])) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1146 fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1147 os.path.dirname(pycompat.fsencode(os.__file__))) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1148 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1149 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
|
1150 if sslutil.hassni: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1151 security.add('sni') |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1152 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1153 fm.write('pythonsecurity', _("checking Python security support (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1154 fm.formatlist(sorted(security), name='protocol', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1155 fmt='%s', sep=',')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1156 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1157 # 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
|
1158 # may change in the future. |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1159 if 'tls1.2' not in security: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1160 fm.plain(_(' TLS 1.2 not supported by Python install; ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1161 'network connections lack modern security\n')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1162 if 'sni' not in security: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1163 fm.plain(_(' SNI not supported by Python install; may have ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1164 'connectivity issues with some servers\n')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1165 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1166 # 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
|
1167 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1168 # hg version |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1169 hgver = util.version() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1170 fm.write('hgver', _("checking Mercurial version (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1171 hgver.split('+')[0]) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1172 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1173 '+'.join(hgver.split('+')[1:])) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1174 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1175 # compiled modules |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1176 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1177 policy.policy) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1178 fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
31091
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31044
diff
changeset
|
1179 os.path.dirname(pycompat.fsencode(__file__))) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1180 |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1181 if policy.policy in ('c', 'allow'): |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1182 err = None |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1183 try: |
32406
a9c71d578a1c
osutil: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32402
diff
changeset
|
1184 from .cext import ( |
32407
008d37c4d783
base85: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32406
diff
changeset
|
1185 base85, |
32408
3b88a7fa97d8
bdiff: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32407
diff
changeset
|
1186 bdiff, |
32410
151cc3b3d799
mpatch: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32408
diff
changeset
|
1187 mpatch, |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1188 osutil, |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1189 ) |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1190 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1191 except Exception as inst: |
34145
ada8a19672ab
debuginstall: do not pass exception object to formatter (issue5676)
Yuya Nishihara <yuya@tcha.org>
parents:
34144
diff
changeset
|
1192 err = util.forcebytestr(inst) |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1193 problems += 1 |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1194 fm.condwrite(err, 'extensionserror', " %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
|
1195 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1196 compengines = util.compengines._engines.values() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1197 fm.write('compengines', _('checking registered compression engines (%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1198 fm.formatlist(sorted(e.name() for e in compengines), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1199 name='compengine', fmt='%s', sep=', ')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1200 fm.write('compenginesavail', _('checking available compression engines ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1201 '(%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1202 fm.formatlist(sorted(e.name() for e in compengines |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1203 if e.available()), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1204 name='compengine', fmt='%s', sep=', ')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1205 wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1206 fm.write('compenginesserver', _('checking available compression engines ' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1207 'for wire protocol (%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1208 fm.formatlist([e.name() for e in wirecompengines |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1209 if e.wireprotosupport()], |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1210 name='compengine', fmt='%s', sep=', ')) |
35452
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1211 re2 = 'missing' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1212 if util._re2: |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1213 re2 = 'available' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1214 fm.plain(_('checking "re2" regexp engine (%s)\n') % re2) |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1215 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
|
1216 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1217 # templates |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1218 p = templater.templatepaths() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1219 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1220 fm.condwrite(not p, '', _(" no template directories found\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1221 if p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1222 m = templater.templatepath("map-cmdline.default") |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1223 if m: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1224 # 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
|
1225 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1226 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1227 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
|
1228 except Exception as inst: |
34145
ada8a19672ab
debuginstall: do not pass exception object to formatter (issue5676)
Yuya Nishihara <yuya@tcha.org>
parents:
34144
diff
changeset
|
1229 err = util.forcebytestr(inst) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1230 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1231 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1232 else: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1233 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1234 fm.condwrite(p, 'defaulttemplate', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1235 _("checking default template (%s)\n"), m) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1236 fm.condwrite(not m, 'defaulttemplatenotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1237 _(" template '%s' not found\n"), "default") |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1238 if not p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1239 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1240 fm.condwrite(not p, '', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1241 _(" (templates seem to have been installed incorrectly)\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1242 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1243 # editor |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1244 editor = ui.geteditor() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1245 editor = util.expandpath(editor) |
36445
0cb09c322647
util: factor out shellsplit() function
Yuya Nishihara <yuya@tcha.org>
parents:
36429
diff
changeset
|
1246 editorbin = util.shellsplit(editor)[0] |
36273
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36191
diff
changeset
|
1247 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) |
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36191
diff
changeset
|
1248 cmdpath = util.findexe(editorbin) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1249 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1250 _(" No commit editor set and can't find %s in PATH\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1251 " (specify a commit editor in your configuration" |
36273
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36191
diff
changeset
|
1252 " file)\n"), not cmdpath and editor == 'vi' and editorbin) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1253 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1254 _(" Can't find editor '%s' in PATH\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1255 " (specify a commit editor in your configuration" |
36273
564dec70b50c
debugcommands: print out the editor that was searched for (post shlexsplit)
Kyle Lippincott <spectral@google.com>
parents:
36191
diff
changeset
|
1256 " file)\n"), not cmdpath and editorbin) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1257 if not cmdpath and editor != 'vi': |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1258 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1259 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1260 # check username |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1261 username = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1262 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1263 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1264 username = ui.username() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1265 except error.Abort as e: |
34145
ada8a19672ab
debuginstall: do not pass exception object to formatter (issue5676)
Yuya Nishihara <yuya@tcha.org>
parents:
34144
diff
changeset
|
1266 err = util.forcebytestr(e) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1267 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1268 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1269 fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1270 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1271 " (specify a username in your configuration file)\n"), err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1272 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1273 fm.condwrite(not problems, '', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1274 _("no problems detected\n")) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1275 if not problems: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1276 fm.data(problems=problems) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1277 fm.condwrite(problems, 'problems', |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1278 _("%d problems detected," |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1279 " please check your install!\n"), problems) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1280 fm.end() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1281 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1282 return problems |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1283 |
30939
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1284 @command('debugknown', [], _('REPO ID...'), norepo=True) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1285 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
|
1286 """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
|
1287 |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1288 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
|
1289 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
|
1290 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1291 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
|
1292 repo = hg.peer(ui, opts, repopath) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1293 if not repo.capable('known'): |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1294 raise error.Abort("known() not supported by target repository") |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1295 flags = repo.known([bin(s) for s in ids]) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1296 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1297 |
30955
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1298 @command('debuglabelcomplete', [], _('LABEL...')) |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1299 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
|
1300 '''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
|
1301 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
|
1302 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1303 @command('debuglocks', |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1304 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1305 ('W', 'force-wlock', None, |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1306 _('free the working state lock (DANGEROUS)')), |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1307 ('s', 'set-lock', None, _('set the store lock until stopped')), |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1308 ('S', 'set-wlock', None, |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1309 _('set the working state lock until stopped'))], |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1310 _('[OPTION]...')) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1311 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
|
1312 """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
|
1313 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1314 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
|
1315 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
|
1316 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
|
1317 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
|
1318 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1319 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
|
1320 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
|
1321 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
|
1322 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
|
1323 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1324 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
|
1325 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
|
1326 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
|
1327 |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1328 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
|
1329 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
|
1330 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
|
1331 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1332 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
|
1333 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1334 """ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1335 |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1336 if opts.get(r'force_lock'): |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1337 repo.svfs.unlink('lock') |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1338 if opts.get(r'force_wlock'): |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1339 repo.vfs.unlink('wlock') |
35401
a43b2dd95e4f
debuglocks: add tests (and fix typo in early return)
Paul Morelle <paul.morelle@octobus.net>
parents:
35387
diff
changeset
|
1340 if opts.get(r'force_lock') or opts.get(r'force_wlock'): |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1341 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1342 |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1343 locks = [] |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1344 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1345 if opts.get(r'set_wlock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1346 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1347 locks.append(repo.wlock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1348 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1349 raise error.Abort(_('wlock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1350 if opts.get(r'set_lock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1351 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1352 locks.append(repo.lock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1353 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1354 raise error.Abort(_('lock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1355 if len(locks): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1356 ui.promptchoice(_("ready to release the lock (y)? $$ &Yes")) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1357 return 0 |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1358 finally: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1359 release(*locks) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1360 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1361 now = time.time() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1362 held = 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1363 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1364 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
|
1365 # 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
|
1366 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1367 l = method(False) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1368 except error.LockHeld: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1369 l = None |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1370 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1371 if l: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1372 l.release() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1373 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1374 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1375 stat = vfs.lstat(name) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1376 age = now - stat.st_mtime |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1377 user = util.username(stat.st_uid) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1378 locker = vfs.readlock(name) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1379 if ":" in locker: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1380 host, pid = locker.split(':') |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1381 if host == socket.gethostname(): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1382 locker = 'user %s, process %s' % (user, pid) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1383 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1384 locker = 'user %s, process %s, host %s' \ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1385 % (user, pid, host) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1386 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1387 return 1 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1388 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
|
1389 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
|
1390 raise |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1391 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1392 ui.write(("%-6s free\n") % (name + ":")) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1393 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1394 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1395 held += report(repo.svfs, "lock", repo.lock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1396 held += report(repo.vfs, "wlock", repo.wlock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1397 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1398 return held |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1399 |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1400 @command('debugmergestate', [], '') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1401 def debugmergestate(ui, repo, *args): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1402 """print merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1403 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1404 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
|
1405 was chosen.""" |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1406 def _hashornull(h): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1407 if h == nullhex: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1408 return 'null' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1409 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1410 return h |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1411 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1412 def printrecords(version): |
36191
72d155a792b1
debugcommands: mergestate version is an int, use %d on it
Augie Fackler <augie@google.com>
parents:
36161
diff
changeset
|
1413 ui.write(('* version %d records\n') % version) |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1414 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1415 records = v1records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1416 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1417 records = v2records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1418 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1419 for rtype, record in records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1420 # pretty print some record types |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1421 if rtype == 'L': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1422 ui.write(('local: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1423 elif rtype == 'O': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1424 ui.write(('other: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1425 elif rtype == 'm': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1426 driver, mdstate = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1427 ui.write(('merge driver: %s (state "%s")\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1428 % (driver, mdstate)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1429 elif rtype in 'FDC': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1430 r = record.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1431 f, state, hash, lfile, afile, anode, ofile = r[0:7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1432 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1433 onode = 'not stored in v1 format' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1434 flags = r[7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1435 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1436 onode, flags = r[7:9] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1437 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1438 % (f, rtype, state, _hashornull(hash))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1439 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1440 ui.write((' ancestor path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1441 % (afile, _hashornull(anode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1442 ui.write((' other path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1443 % (ofile, _hashornull(onode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1444 elif rtype == 'f': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1445 filename, rawextras = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1446 extras = rawextras.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1447 i = 0 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1448 extrastrings = [] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1449 while i < len(extras): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1450 extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1451 i += 2 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1452 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1453 ui.write(('file extras: %s (%s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1454 % (filename, ', '.join(extrastrings))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1455 elif rtype == 'l': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1456 labels = record.split('\0', 2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1457 labels = [l for l in labels if len(l) > 0] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1458 ui.write(('labels:\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1459 ui.write((' local: %s\n' % labels[0])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1460 ui.write((' other: %s\n' % labels[1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1461 if len(labels) > 2: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1462 ui.write((' base: %s\n' % labels[2])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1463 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1464 ui.write(('unrecognized entry: %s\t%s\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1465 % (rtype, record.replace('\0', '\t'))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1466 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1467 # Avoid mergestate.read() since it may raise an exception for unsupported |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1468 # merge state records. We shouldn't be doing this, but this is OK since this |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1469 # command is pretty low-level. |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1470 ms = mergemod.mergestate(repo) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1471 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1472 # sort so that reasonable information is on top |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1473 v1records = ms._readrecordsv1() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1474 v2records = ms._readrecordsv2() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1475 order = 'LOml' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1476 def key(r): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1477 idx = order.find(r[0]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1478 if idx == -1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1479 return (1, r[1]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1480 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1481 return (0, idx) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1482 v1records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1483 v2records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1484 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1485 if not v1records and not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1486 ui.write(('no merge state found\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1487 elif not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1488 ui.note(('no version 2 merge state\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1489 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1490 elif ms._v1v2match(v1records, v2records): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1491 ui.note(('v1 and v2 states match: using v2\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1492 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1493 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1494 ui.note(('v1 and v2 states mismatch: using v1\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1495 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1496 if ui.verbose: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1497 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1498 |
30957
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1499 @command('debugnamecomplete', [], _('NAME...')) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1500 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
|
1501 '''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
|
1502 |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1503 names = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1504 # 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
|
1505 # specially (after this for loop) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1506 for name, ns in repo.names.iteritems(): |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1507 if name != 'branches': |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1508 names.update(ns.listnames(repo)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1509 names.update(tag for (tag, heads, tip, closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1510 in repo.branchmap().iterbranches() if not closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1511 completions = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1512 if not args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1513 args = [''] |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1514 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
|
1515 completions.update(n for n in names if n.startswith(a)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1516 ui.write('\n'.join(sorted(completions))) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1517 ui.write('\n') |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1518 |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1519 @command('debugobsolete', |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1520 [('', 'flags', 0, _('markers flag')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1521 ('', 'record-parents', False, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1522 _('record parent information for the precursor')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1523 ('r', 'rev', [], _('display markers relevant to REV')), |
32649
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32550
diff
changeset
|
1524 ('', 'exclusive', False, _('restrict display to markers only ' |
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32550
diff
changeset
|
1525 'relevant to REV')), |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1526 ('', 'index', False, _('display index of the marker')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1527 ('', 'delete', [], _('delete markers specified by indices')), |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1528 ] + cmdutil.commitopts2 + cmdutil.formatteropts, |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1529 _('[OBSOLETED [REPLACEMENT ...]]')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1530 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
|
1531 """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
|
1532 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1533 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
|
1534 |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1535 opts = pycompat.byteskwargs(opts) |
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1536 |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1537 def parsenodeid(s): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1538 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1539 # 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
|
1540 # 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
|
1541 # local repository. |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1542 n = bin(s) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1543 if len(n) != len(nullid): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1544 raise TypeError() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1545 return n |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1546 except TypeError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1547 raise error.Abort('changeset references must be full hexadecimal ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1548 'node identifiers') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1549 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1550 if opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1551 indices = [] |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1552 for v in opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1553 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1554 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
|
1555 except ValueError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1556 raise error.Abort(_('invalid index value: %r') % v, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1557 hint=_('use integers for indices')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1558 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1559 if repo.currenttransaction(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1560 raise error.Abort(_('cannot delete obsmarkers in the middle ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1561 'of transaction.')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1562 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1563 with repo.lock(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1564 n = repair.deleteobsmarkers(repo.obsstore, indices) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1565 ui.write(_('deleted %i obsolescence markers\n') % n) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1566 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1567 return |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1568 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1569 if precursor is not None: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1570 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1571 raise error.Abort('cannot select revision when creating marker') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1572 metadata = {} |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1573 metadata['user'] = opts['user'] or ui.username() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1574 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
|
1575 l = repo.lock() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1576 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1577 tr = repo.transaction('debugobsolete') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1578 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1579 date = opts.get('date') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1580 if date: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1581 date = util.parsedate(date) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1582 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1583 date = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1584 prec = parsenodeid(precursor) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1585 parents = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1586 if opts['record_parents']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1587 if prec not in repo.unfiltered(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1588 raise error.Abort('cannot used --record-parents on ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1589 'unknown changesets') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1590 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
|
1591 parents = tuple(p.node() for p in parents) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1592 repo.obsstore.create(tr, prec, succs, opts['flags'], |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1593 parents=parents, date=date, |
32449
08d02c1d7e67
devel: use default-date config field when creating obsmarkers
Boris Feld <boris.feld@octobus.net>
parents:
32444
diff
changeset
|
1594 metadata=metadata, ui=ui) |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1595 tr.close() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1596 except ValueError as exc: |
36522
6e90c59b6da1
py3: use pycompat.bytestr() to convert error instances to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36489
diff
changeset
|
1597 raise error.Abort(_('bad obsmarker input: %s') % |
6e90c59b6da1
py3: use pycompat.bytestr() to convert error instances to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36489
diff
changeset
|
1598 pycompat.bytestr(exc)) |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1599 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1600 tr.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1601 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1602 l.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1603 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1604 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1605 revs = scmutil.revrange(repo, opts['rev']) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1606 nodes = [repo[r].node() for r in revs] |
33155
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33154
diff
changeset
|
1607 markers = list(obsutil.getmarkers(repo, nodes=nodes, |
32649
00a7f7b1af9c
obsolete: add a function to compute "exclusive-markers" for a set of nodes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32550
diff
changeset
|
1608 exclusive=opts['exclusive'])) |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1609 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
|
1610 else: |
33155
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33154
diff
changeset
|
1611 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
|
1612 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1613 markerstoiter = markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1614 isrelevant = lambda m: True |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1615 if opts.get('rev') and opts.get('index'): |
33155
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33154
diff
changeset
|
1616 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
|
1617 markerset = set(markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1618 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
|
1619 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1620 fm = ui.formatter('debugobsolete', opts) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1621 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
|
1622 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
|
1623 # 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
|
1624 # 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
|
1625 # 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
|
1626 # 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
|
1627 # 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
|
1628 # 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
|
1629 # 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
|
1630 continue |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1631 fm.startitem() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1632 ind = i if opts.get('index') else None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1633 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
|
1634 fm.end() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1635 |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1636 @command('debugpathcomplete', |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1637 [('f', 'full', None, _('complete an entire path')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1638 ('n', 'normal', None, _('show only normal files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1639 ('a', 'added', None, _('show only added files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1640 ('r', 'removed', None, _('show only removed files'))], |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1641 _('FILESPEC...')) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1642 def debugpathcomplete(ui, repo, *specs, **opts): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1643 '''complete part or all of a tracked path |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1644 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1645 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
|
1646 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
|
1647 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1648 Completion extends only to the next path segment unless |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1649 --full is specified, in which case entire paths are used.''' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1650 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1651 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
|
1652 dirstate = repo.dirstate |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1653 spec = os.path.normpath(os.path.join(pycompat.getcwd(), path)) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1654 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
|
1655 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
|
1656 return [], [] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1657 if os.path.isdir(spec): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1658 spec += '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1659 spec = spec[len(rootdir):] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1660 fixpaths = pycompat.ossep != '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1661 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1662 spec = spec.replace(pycompat.ossep, '/') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1663 speclen = len(spec) |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1664 fullpaths = opts[r'full'] |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1665 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
|
1666 adddir, addfile = dirs.add, files.add |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1667 for f, st in dirstate.iteritems(): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1668 if f.startswith(spec) and st[0] in acceptable: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1669 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1670 f = f.replace('/', pycompat.ossep) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1671 if fullpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1672 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1673 continue |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1674 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
|
1675 if s >= 0: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1676 adddir(f[:s]) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1677 else: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1678 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1679 return files, dirs |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1680 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1681 acceptable = '' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1682 if opts[r'normal']: |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1683 acceptable += 'nm' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1684 if opts[r'added']: |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1685 acceptable += 'a' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1686 if opts[r'removed']: |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1687 acceptable += 'r' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1688 cwd = repo.getcwd() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1689 if not specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1690 specs = ['.'] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1691 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1692 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
|
1693 for spec in specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1694 f, d = complete(spec, acceptable or 'nmar') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1695 files.update(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1696 dirs.update(d) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1697 files.update(dirs) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1698 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1699 ui.write('\n') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1700 |
35969
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1701 @command('debugpeer', [], _('PATH'), norepo=True) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1702 def debugpeer(ui, path): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1703 """establish a connection to a peer repository""" |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1704 # Always enable peer request logging. Requires --debug to display |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1705 # though. |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1706 overrides = { |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1707 ('devel', 'debug.peer-request'): True, |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1708 } |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1709 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1710 with ui.configoverride(overrides): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1711 peer = hg.peer(ui, {}, path) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1712 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1713 local = peer.local() is not None |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1714 canpush = peer.canpush() |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1715 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1716 ui.write(_('url: %s\n') % peer.url()) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1717 ui.write(_('local: %s\n') % (_('yes') if local else _('no'))) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1718 ui.write(_('pushable: %s\n') % (_('yes') if canpush else _('no'))) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1719 |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1720 @command('debugpickmergetool', |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1721 [('r', 'rev', '', _('check for files in this revision'), _('REV')), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1722 ('', 'changedelete', None, _('emulate merging change and delete')), |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1723 ] + cmdutil.walkopts + cmdutil.mergetoolopts, |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1724 _('[PATTERN]...'), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1725 inferrepo=True) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1726 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
|
1727 """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
|
1728 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1729 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
|
1730 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
|
1731 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
|
1732 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 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
|
1738 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
|
1739 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
|
1740 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1741 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
|
1742 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1743 FILE = MERGETOOL |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1744 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1745 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
|
1746 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
|
1747 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
|
1748 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
|
1749 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1750 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
|
1751 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
|
1752 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
|
1753 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
|
1754 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
|
1755 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1756 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
|
1757 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
|
1758 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1759 - ``--tool`` option |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1760 - ``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
|
1761 - 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
|
1762 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1763 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
|
1764 ``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
|
1765 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
|
1766 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
|
1767 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1768 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
|
1769 overrides = {} |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1770 if opts['tool']: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1771 overrides[('ui', 'forcemerge')] = opts['tool'] |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1772 ui.note(('with --tool %r\n') % (opts['tool'])) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1773 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1774 with ui.configoverride(overrides, 'debugmergepatterns'): |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1775 hgmerge = encoding.environ.get("HGMERGE") |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1776 if hgmerge is not None: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1777 ui.note(('with HGMERGE=%r\n') % (hgmerge)) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1778 uimerge = ui.config("ui", "merge") |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1779 if uimerge: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1780 ui.note(('with ui.merge=%r\n') % (uimerge)) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1781 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1782 ctx = scmutil.revsingle(repo, opts.get('rev')) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1783 m = scmutil.match(ctx, pats, opts) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1784 changedelete = opts['changedelete'] |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1785 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
|
1786 fctx = ctx[path] |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1787 try: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1788 if not ui.debugflag: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1789 ui.pushbuffer(error=True) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1790 tool, toolpath = filemerge._picktool(repo, ui, path, |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1791 fctx.isbinary(), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1792 'l' in fctx.flags(), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1793 changedelete) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1794 finally: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1795 if not ui.debugflag: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1796 ui.popbuffer() |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1797 ui.write(('%s = %s\n') % (path, tool)) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1798 |
30966
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1799 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1800 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1801 '''access the pushkey key/value protocol |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1802 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1803 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
|
1804 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1805 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
|
1806 Reports success or failure. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1807 ''' |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1808 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1809 target = hg.peer(ui, {}, repopath) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1810 if keyinfo: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1811 key, old, new = keyinfo |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1812 r = target.pushkey(namespace, key, old, new) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1813 ui.status(str(r) + '\n') |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1814 return not r |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1815 else: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1816 for k, v in sorted(target.listkeys(namespace).iteritems()): |
31460
53865692a354
util: wrap s.encode('string_escape') call for future py3 compatibility
Yuya Nishihara <yuya@tcha.org>
parents:
31411
diff
changeset
|
1817 ui.write("%s\t%s\n" % (util.escapestr(k), |
53865692a354
util: wrap s.encode('string_escape') call for future py3 compatibility
Yuya Nishihara <yuya@tcha.org>
parents:
31411
diff
changeset
|
1818 util.escapestr(v))) |
30966
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1819 |
30967
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1820 @command('debugpvec', [], _('A B')) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1821 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
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 if pa == pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1827 rel = "=" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1828 elif pa > pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1829 rel = ">" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1830 elif pa < pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1831 rel = "<" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1832 elif pa | pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1833 rel = "|" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1834 ui.write(_("a: %s\n") % pa) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1835 ui.write(_("b: %s\n") % pb) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1836 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1837 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1838 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1839 pa.distance(pb), rel)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1840 |
30968
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1841 @command('debugrebuilddirstate|debugrebuildstate', |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1842 [('r', 'rev', '', _('revision to rebuild to'), _('REV')), |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1843 ('', 'minimal', None, _('only rebuild files that are inconsistent with ' |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1844 '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
|
1845 ], |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1846 _('[-r REV]')) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1847 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
|
1848 """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
|
1849 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1850 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
|
1851 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1852 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
|
1853 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
|
1854 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
|
1855 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1856 ``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
|
1857 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
|
1858 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
|
1859 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
|
1860 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1861 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
|
1862 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
|
1863 """ |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1864 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
|
1865 with repo.wlock(): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1866 dirstate = repo.dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1867 changedfiles = None |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1868 # See command doc for what minimal does. |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1869 if opts.get(r'minimal'): |
30968
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1870 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
|
1871 dirstatefiles = set(dirstate) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1872 manifestonly = manifestfiles - dirstatefiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1873 dsonly = dirstatefiles - manifestfiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1874 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1875 changedfiles = manifestonly | dsnotadded |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1876 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1877 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
|
1878 |
30969
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1879 @command('debugrebuildfncache', [], '') |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1880 def debugrebuildfncache(ui, repo): |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1881 """rebuild the fncache file""" |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1882 repair.rebuildfncache(ui, repo) |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1883 |
30970
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1884 @command('debugrename', |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1885 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1886 _('[-r REV] FILE')) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1887 def debugrename(ui, repo, file1, *pats, **opts): |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1888 """dump rename information""" |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1889 |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1890 opts = pycompat.byteskwargs(opts) |
30970
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1891 ctx = scmutil.revsingle(repo, opts.get('rev')) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1892 m = scmutil.match(ctx, (file1,) + pats, opts) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1893 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
|
1894 fctx = ctx[abs] |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1895 o = fctx.filelog().renamed(fctx.filenode()) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1896 rel = m.rel(abs) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1897 if o: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1898 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1899 else: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1900 ui.write(_("%s not renamed\n") % rel) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1901 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1902 @command('debugrevlog', cmdutil.debugrevlogopts + |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1903 [('d', 'dump', False, _('dump index data'))], |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1904 _('-c|-m|FILE'), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1905 optionalrepo=True) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1906 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
|
1907 """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
|
1908 opts = pycompat.byteskwargs(opts) |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1909 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1910 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1911 if opts.get("dump"): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1912 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1913 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1914 " rawsize totalsize compression heads chainlen\n")) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1915 ts = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1916 heads = set() |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1917 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1918 for rev in xrange(numrevs): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1919 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
|
1920 if dbase == -1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1921 dbase = rev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1922 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
|
1923 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
|
1924 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
|
1925 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
|
1926 ts = ts + rs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1927 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
|
1928 heads.add(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1929 try: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1930 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
|
1931 except ZeroDivisionError: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1932 compression = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1933 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1934 "%11d %5d %8d\n" % |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1935 (rev, p1, p2, r.start(rev), r.end(rev), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1936 r.start(dbase), r.start(cbase), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1937 r.start(p1), r.start(p2), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1938 rs, ts, compression, len(heads), clen)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1939 return 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1940 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1941 v = r.version |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1942 format = v & 0xFFFF |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1943 flags = [] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1944 gdelta = False |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
1945 if v & revlog.FLAG_INLINE_DATA: |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1946 flags.append('inline') |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
1947 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
|
1948 gdelta = True |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1949 flags.append('generaldelta') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1950 if not flags: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1951 flags = ['(none)'] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1952 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1953 nummerges = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1954 numfull = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1955 numprev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1956 nump1 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1957 nump2 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1958 numother = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1959 nump1prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1960 nump2prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1961 chainlengths = [] |
33069
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
1962 chainbases = [] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
1963 chainspans = [] |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1964 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1965 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
|
1966 fullsize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1967 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
|
1968 chunktypecounts = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1969 chunktypesizes = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1970 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1971 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
|
1972 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
|
1973 l[0] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1974 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
|
1975 l[1] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1976 l[2] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1977 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1978 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1979 for rev in xrange(numrevs): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1980 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
|
1981 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
|
1982 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1983 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
|
1984 if p2 != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1985 nummerges += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1986 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
|
1987 if delta == nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1988 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
|
1989 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
|
1990 chainspans.append(size) |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1991 numfull += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1992 addsize(size, fullsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1993 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1994 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
|
1995 baseaddr = chainbases[delta] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
1996 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
|
1997 chainbases.append(baseaddr) |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
1998 chainspans.append((revaddr - baseaddr) + size) |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
1999 addsize(size, deltasize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2000 if delta == rev - 1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2001 numprev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2002 if delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2003 nump1prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2004 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2005 nump2prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2006 elif delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2007 nump1 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2008 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2009 nump2 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2010 elif delta != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2011 numother += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2012 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2013 # Obtain data on the raw chunks in the revlog. |
32269
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32249
diff
changeset
|
2014 segment = r._getsegmentforrevs(rev, rev)[1] |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32249
diff
changeset
|
2015 if segment: |
33118
2f812b0d1936
py3: pass the memoryview object into bytes() to get the value
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33114
diff
changeset
|
2016 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
|
2017 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2018 chunktype = 'empty' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2019 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2020 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
|
2021 chunktypecounts[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2022 chunktypesizes[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2023 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2024 chunktypecounts[chunktype] += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2025 chunktypesizes[chunktype] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2026 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2027 # Adjust size min value for empty cases |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2028 for size in (datasize, fullsize, deltasize): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2029 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
|
2030 size[0] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2031 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2032 numdeltas = numrevs - numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2033 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
|
2034 totalrawsize = datasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2035 datasize[2] /= numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2036 fulltotal = fullsize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2037 fullsize[2] /= numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2038 deltatotal = deltasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2039 if numrevs - numfull > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2040 deltasize[2] /= numrevs - numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2041 totalsize = fulltotal + deltatotal |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2042 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
|
2043 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
|
2044 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
|
2045 compratio = 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2046 if totalsize: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2047 compratio = totalrawsize / totalsize |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2048 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2049 basedfmtstr = '%%%dd\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2050 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2051 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2052 def dfmtstr(max): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2053 return basedfmtstr % len(str(max)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2054 def pcfmtstr(max, padding=0): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2055 return basepcfmtstr % (len(str(max)), ' ' * padding) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2056 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2057 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
|
2058 if total: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2059 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
|
2060 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2061 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
|
2062 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2063 ui.write(('format : %d\n') % format) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2064 ui.write(('flags : %s\n') % ', '.join(flags)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2065 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2066 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2067 fmt = pcfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2068 fmt2 = dfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2069 ui.write(('revisions : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2070 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2071 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2072 ui.write(('revisions : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2073 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2074 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2075 ui.write(('revision size : ') + fmt2 % totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2076 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2077 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2078 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2079 def fmtchunktype(chunktype): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2080 if chunktype == 'empty': |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2081 return ' %s : ' % chunktype |
33119
e88fdec9cb9e
py3: use pycompat.bytestr() to convert str to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33118
diff
changeset
|
2082 elif chunktype in pycompat.bytestr(string.ascii_letters): |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2083 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2084 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2085 return ' 0x%s : ' % hex(chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2086 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2087 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2088 ui.write(('chunks : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2089 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
|
2090 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
|
2091 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2092 ui.write(('chunks size : ') + fmt2 % totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2093 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
|
2094 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
|
2095 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
|
2096 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2097 ui.write('\n') |
33074
e21b750c9b9e
debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents:
33069
diff
changeset
|
2098 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2099 ui.write(('avg chain length : ') + fmt % avgchainlen) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2100 ui.write(('max chain length : ') + fmt % maxchainlen) |
33074
e21b750c9b9e
debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents:
33069
diff
changeset
|
2101 ui.write(('max chain reach : ') + fmt % maxchainspan) |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2102 ui.write(('compression ratio : ') + fmt % compratio) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2103 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2104 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2105 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2106 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2107 % tuple(datasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2108 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2109 % tuple(fullsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2110 ui.write(('delta size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2111 % tuple(deltasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2112 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2113 if numdeltas > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2114 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2115 fmt = pcfmtstr(numdeltas) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2116 fmt2 = pcfmtstr(numdeltas, 4) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2117 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2118 if numprev > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2119 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2120 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2121 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2122 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2123 ui.write((' other : ') + fmt2 % pcfmt(numoprev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2124 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2125 if gdelta: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2126 ui.write(('deltas against p1 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2127 + fmt % pcfmt(nump1, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2128 ui.write(('deltas against p2 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2129 + fmt % pcfmt(nump2, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2130 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2131 numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2132 |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2133 @command('debugrevspec', |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2134 [('', 'optimize', None, |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2135 _('print parsed tree after optimizing (DEPRECATED)')), |
32816
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2136 ('', 'show-revs', True, _('print list of result revisions (default)')), |
32815
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2137 ('s', 'show-set', None, _('print internal representation of result set')), |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2138 ('p', 'show-stage', [], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2139 _('print parsed tree at the given stage'), _('NAME')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2140 ('', 'no-optimized', False, _('evaluate tree without optimization')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2141 ('', 'verify-optimized', False, _('verify optimized result')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2142 ], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2143 ('REVSPEC')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2144 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
|
2145 """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
|
2146 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2147 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
|
2148 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
|
2149 |
32816
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2150 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
|
2151 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
|
2152 |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2153 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
|
2154 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
|
2155 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
2156 opts = pycompat.byteskwargs(opts) |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2157 aliases = ui.configitems('revsetalias') |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2158 stages = [ |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2159 ('parsed', lambda tree: tree), |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2160 ('expanded', lambda tree: revsetlang.expandaliases(tree, aliases, |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2161 ui.warn)), |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2162 ('concatenated', revsetlang.foldconcat), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2163 ('analyzed', revsetlang.analyze), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2164 ('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
|
2165 ] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2166 if opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2167 stages = stages[:-1] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2168 if opts['verify_optimized'] and opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2169 raise error.Abort(_('cannot use --verify-optimized with ' |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2170 '--no-optimized')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2171 stagenames = set(n for n, f in stages) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2172 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2173 showalways = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2174 showchanged = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2175 if ui.verbose and not opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2176 # show parsed tree by --verbose (deprecated) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2177 showalways.add('parsed') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2178 showchanged.update(['expanded', 'concatenated']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2179 if opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2180 showalways.add('optimized') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2181 if opts['show_stage'] and opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2182 raise error.Abort(_('cannot use --optimize with --show-stage')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2183 if opts['show_stage'] == ['all']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2184 showalways.update(stagenames) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2185 else: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2186 for n in opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2187 if n not in stagenames: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2188 raise error.Abort(_('invalid stage name: %s') % n) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2189 showalways.update(opts['show_stage']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2190 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2191 treebystage = {} |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2192 printedtree = None |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2193 tree = revsetlang.parse(expr, lookup=repo.__contains__) |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2194 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
|
2195 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
|
2196 if n in showalways or (n in showchanged and tree != printedtree): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2197 if opts['show_stage'] or n != 'parsed': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2198 ui.write(("* %s:\n") % n) |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2199 ui.write(revsetlang.prettyformat(tree), "\n") |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2200 printedtree = tree |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2201 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2202 if opts['verify_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2203 arevs = revset.makematcher(treebystage['analyzed'])(repo) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2204 brevs = revset.makematcher(treebystage['optimized'])(repo) |
32815
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2205 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2206 ui.write(("* analyzed set:\n"), smartset.prettyformat(arevs), "\n") |
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2207 ui.write(("* optimized set:\n"), smartset.prettyformat(brevs), "\n") |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2208 arevs = list(arevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2209 brevs = list(brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2210 if arevs == brevs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2211 return 0 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2212 ui.write(('--- analyzed\n'), label='diff.file_a') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2213 ui.write(('+++ optimized\n'), label='diff.file_b') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2214 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
|
2215 for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2216 if tag in ('delete', 'replace'): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2217 for c in arevs[alo:ahi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2218 ui.write('-%s\n' % c, label='diff.deleted') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2219 if tag in ('insert', 'replace'): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2220 for c in brevs[blo:bhi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2221 ui.write('+%s\n' % c, label='diff.inserted') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2222 if tag == 'equal': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2223 for c in arevs[alo:ahi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2224 ui.write(' %s\n' % c) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2225 return 1 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2226 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2227 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
|
2228 revs = func(repo) |
32815
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2229 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2230 ui.write(("* set:\n"), smartset.prettyformat(revs), "\n") |
32816
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2231 if not opts['show_revs']: |
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2232 return |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2233 for c in revs: |
35942
2da4144e6716
py3: format revision number as '%d' in debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
35928
diff
changeset
|
2234 ui.write("%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
|
2235 |
36556
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2236 @command('debugserve', [ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2237 ('', 'sshstdio', False, _('run an SSH server bound to process handles')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2238 ('', 'logiofd', '', _('file descriptor to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2239 ('', 'logiofile', '', _('file to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2240 ], '') |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2241 def debugserve(ui, repo, **opts): |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2242 """run a server with advanced settings |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2243 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2244 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
|
2245 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
|
2246 arguments for security reasons. |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2247 """ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2248 opts = pycompat.byteskwargs(opts) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2249 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2250 if not opts['sshstdio']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2251 raise error.Abort(_('only --sshstdio is currently supported')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2252 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2253 logfh = None |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2254 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2255 if opts['logiofd'] and opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2256 raise error.Abort(_('cannot use both --logiofd and --logiofile')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2257 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2258 if opts['logiofd']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2259 # Line buffered because output is line based. |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2260 logfh = os.fdopen(int(opts['logiofd']), 'ab', 1) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2261 elif opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2262 logfh = open(opts['logiofile'], 'ab', 1) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2263 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2264 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2265 s.serve_forever() |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2266 |
30973
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2267 @command('debugsetparents', [], _('REV1 [REV2]')) |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2268 def debugsetparents(ui, repo, rev1, rev2=None): |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2269 """manually set the parents of the current working directory |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2270 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2271 This is useful for writing repository conversion tools, but should |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2272 be used with care. For example, neither the working directory nor the |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2273 dirstate is updated, so file status may be incorrect after running this |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2274 command. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2275 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2276 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
|
2277 """ |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2278 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2279 r1 = scmutil.revsingle(repo, rev1).node() |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2280 r2 = scmutil.revsingle(repo, rev2, 'null').node() |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2281 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2282 with repo.wlock(): |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2283 repo.setparents(r1, r2) |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2284 |
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
|
2285 @command('debugssl', [], '[SOURCE]', optionalrepo=True) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2286 def debugssl(ui, repo, source=None, **opts): |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2287 '''test a secure connection to a server |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2288 |
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
|
2289 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
|
2290 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
|
2291 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
|
2292 |
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
|
2293 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
|
2294 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
|
2295 |
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
|
2296 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
|
2297 of the SSL error is likely another issue. |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2298 ''' |
34645 | 2299 if not pycompat.iswindows: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2300 raise error.Abort(_('certificate chain building is only possible on ' |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2301 'Windows')) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2302 |
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
|
2303 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
|
2304 if not repo: |
3c3066367d72
debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
33553
diff
changeset
|
2305 raise error.Abort(_("there is no Mercurial repository here, and no " |
3c3066367d72
debugssl: allow a URL to be specified without a local repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
33553
diff
changeset
|
2306 "server specified")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2307 source = "default" |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2308 |
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
|
2309 source, branches = hg.parseurl(ui.expandpath(source)) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2310 url = util.url(source) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2311 addr = None |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2312 |
35005
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2313 defaultport = {'https': 443, 'ssh': 22} |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2314 if url.scheme in defaultport: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2315 try: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2316 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
|
2317 except ValueError: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2318 raise error.Abort(_("malformed port number in URL")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2319 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2320 raise error.Abort(_("only https and ssh connections are supported")) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2321 |
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
|
2322 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
|
2323 |
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
|
2324 s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS, |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2325 cert_reqs=ssl.CERT_NONE, ca_certs=None) |
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2326 |
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
|
2327 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
|
2328 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
|
2329 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
|
2330 |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2331 ui.status(_('checking the certificate chain for %s\n') % url.host) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2332 |
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
|
2333 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
|
2334 |
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
|
2335 if not complete: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2336 ui.status(_('certificate chain is incomplete, updating... ')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2337 |
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
|
2338 if not win32.checkcertificatechain(cert): |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2339 ui.status(_('failed.\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2340 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2341 ui.status(_('done.\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2342 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2343 ui.status(_('full certificate chain is available\n')) |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
2344 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
|
2345 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
|
2346 |
30975
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2347 @command('debugsub', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2348 [('r', 'rev', '', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2349 _('revision to check'), _('REV'))], |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2350 _('[-r REV] [REV]')) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2351 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
|
2352 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
|
2353 for k, v in sorted(ctx.substate.items()): |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2354 ui.write(('path %s\n') % k) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2355 ui.write((' source %s\n') % v[0]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2356 ui.write((' revision %s\n') % v[1]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2357 |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2358 @command('debugsuccessorssets', |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2359 [('', 'closest', False, _('return closest successors sets only'))], |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2360 _('[REV]')) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2361 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
|
2362 """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
|
2363 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2364 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
|
2365 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
|
2366 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
|
2367 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2368 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
|
2369 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
|
2370 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2371 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
|
2372 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
|
2373 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2374 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
|
2375 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
|
2376 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2377 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
|
2378 "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
|
2379 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
|
2380 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2381 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
|
2382 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2383 <rev1> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2384 <successors-1A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2385 <rev2> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2386 <successors-2A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2387 <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
|
2388 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2389 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
|
2390 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
|
2391 been split). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2392 """ |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2393 # 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
|
2394 cache = {} |
36161
8eb13f5d5d3f
py3: convert context to bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35969
diff
changeset
|
2395 ctx2str = bytes |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2396 node2str = short |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2397 for rev in scmutil.revrange(repo, revs): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2398 ctx = repo[rev] |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2399 ui.write('%s\n'% ctx2str(ctx)) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2400 for succsset in obsutil.successorssets(repo, ctx.node(), |
35408
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35407
diff
changeset
|
2401 closest=opts[r'closest'], |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2402 cache=cache): |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2403 if succsset: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2404 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2405 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
|
2406 for node in succsset[1:]: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2407 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2408 ui.write(node2str(node)) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2409 ui.write('\n') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2410 |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2411 @command('debugtemplate', |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2412 [('r', 'rev', [], _('apply template on changesets'), _('REV')), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2413 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2414 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2415 optionalrepo=True) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2416 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
|
2417 """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
|
2418 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2419 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
|
2420 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
|
2421 template. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2422 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2423 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
|
2424 """ |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2425 revs = None |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
2426 if opts[r'rev']: |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2427 if repo is None: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2428 raise error.RepoError(_('there is no Mercurial repository here ' |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2429 '(.hg not found)')) |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
2430 revs = scmutil.revrange(repo, opts[r'rev']) |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2431 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2432 props = {} |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
2433 for d in opts[r'define']: |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2434 try: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2435 k, v = (e.strip() for e in d.split('=', 1)) |
31523
468bc8a1863d
debugtemplate: pass ui to templater so label() works
Yuya Nishihara <yuya@tcha.org>
parents:
31460
diff
changeset
|
2436 if not k or k == 'ui': |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2437 raise ValueError |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2438 props[k] = v |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2439 except ValueError: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2440 raise error.Abort(_('malformed keyword definition: %s') % d) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2441 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2442 if ui.verbose: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2443 aliases = ui.configitems('templatealias') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2444 tree = templater.parse(tmpl) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2445 ui.note(templater.prettyformat(tree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2446 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
|
2447 if newtree != tree: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2448 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2449 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2450 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
|
2451 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
|
2452 t = formatter.maketemplater(ui, tmpl, resources=tres) |
32891
2ecce24dfcd3
templater: add simple interface for unnamed template (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32855
diff
changeset
|
2453 ui.write(t.render(props)) |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2454 else: |
35928
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
2455 displayer = logcmdutil.maketemplater(ui, repo, tmpl) |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2456 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
|
2457 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
|
2458 displayer.close() |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2459 |
32305
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2460 @command('debugupdatecaches', []) |
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2461 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
|
2462 """warm all known caches in the repository""" |
33438 | 2463 with repo.wlock(), repo.lock(): |
2464 repo.updatecaches() | |
32305
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2465 |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2466 @command('debugupgraderepo', [ |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2467 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2468 ('', 'run', False, _('performs an upgrade')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2469 ]) |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2470 def debugupgraderepo(ui, repo, run=False, optimize=None): |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2471 """upgrade a repository to use different features |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2472 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2473 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
|
2474 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
|
2475 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2476 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
|
2477 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
|
2478 by the command output when run without ``--run``. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2479 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2480 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
|
2481 allowed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2482 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2483 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
|
2484 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
|
2485 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
|
2486 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
|
2487 unable to access the repository should be low. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2488 """ |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31694
diff
changeset
|
2489 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize) |
30978
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2490 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2491 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'), |
30978
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2492 inferrepo=True) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2493 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
|
2494 """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
|
2495 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
|
2496 m = scmutil.match(repo[None], pats, opts) |
32491
2def402bd16d
debugwalk: also print matcher representation
Martin von Zweigbergk <martinvonz@google.com>
parents:
32449
diff
changeset
|
2497 ui.write(('matcher: %r\n' % m)) |
32402
a275186b989a
debugcommands: use repo[None].walk instead of repo.walk
Augie Fackler <augie@google.com>
parents:
32376
diff
changeset
|
2498 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
|
2499 if not items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2500 return |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2501 f = lambda fn: fn |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2502 if ui.configbool('ui', 'slash') and pycompat.ossep != '/': |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2503 f = lambda fn: util.normpath(fn) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2504 fmt = 'f %%-%ds %%-%ds %%s' % ( |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2505 max([len(abs) for abs in items]), |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2506 max([len(m.rel(abs)) for abs in items])) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2507 for abs in items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2508 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '') |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2509 ui.write("%s\n" % line.rstrip()) |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2510 |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2511 @command('debugwireargs', |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2512 [('', 'three', '', 'three'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2513 ('', 'four', '', 'four'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2514 ('', 'five', '', 'five'), |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2515 ] + cmdutil.remoteopts, |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2516 _('REPO [OPTIONS]... [ONE [TWO]]'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2517 norepo=True) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2518 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
|
2519 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
|
2520 repo = hg.peer(ui, opts, repopath) |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2521 for opt in cmdutil.remoteopts: |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2522 del opts[opt[1]] |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2523 args = {} |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2524 for k, v in opts.iteritems(): |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2525 if v: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2526 args[k] = v |
35408
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35407
diff
changeset
|
2527 args = pycompat.strkwargs(args) |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2528 # run twice to check that we don't mess up the stream for the next command |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2529 res1 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2530 res2 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2531 ui.write("%s\n" % res1) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2532 if res1 != res2: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2533 ui.warn("%s\n" % res2) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2534 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2535 def _parsewirelangblocks(fh): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2536 activeaction = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2537 blocklines = [] |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2538 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2539 for line in fh: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2540 line = line.rstrip() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2541 if not line: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2542 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2543 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2544 if line.startswith(b'#'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2545 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2546 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2547 if not line.startswith(' '): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2548 # New block. Flush previous one. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2549 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2550 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2551 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2552 activeaction = line |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2553 blocklines = [] |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2554 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2555 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2556 # Else we start with an indent. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2557 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2558 if not activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2559 raise error.Abort(_('indented line outside of block')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2560 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2561 blocklines.append(line) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2562 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2563 # Flush last block. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2564 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2565 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2566 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2567 @command('debugwireproto', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2568 [ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2569 ('', 'localssh', False, _('start an SSH server for this repo')), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2570 ('', 'peer', '', _('construct a specific version of the peer')), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2571 ] + cmdutil.remoteopts, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2572 _('[REPO]'), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2573 optionalrepo=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2574 def debugwireproto(ui, repo, **opts): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2575 """send wire protocol commands to a server |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2576 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2577 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
|
2578 peers and to debug the raw data being exchanged. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2579 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2580 ``--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
|
2581 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
|
2582 and establish an appropriate peer instance. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2583 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2584 ``--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
|
2585 peer instance using the specified class type. Valid values are ``raw``, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2586 ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending raw data |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2587 payloads and don't support higher-level command actions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2588 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2589 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
|
2590 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
|
2591 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
|
2592 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
|
2593 effectively a high-level command with additional metadata. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2594 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2595 Lines beginning with ``#`` are ignored. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2596 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2597 The following sections denote available actions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2598 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2599 raw |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2600 --- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2601 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2602 Send raw data to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2603 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2604 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
|
2605 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
|
2606 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
|
2607 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2608 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
|
2609 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
|
2610 backslash escaping, etc. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2611 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2612 raw+ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2613 ---- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2614 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2615 Behaves like ``raw`` except flushes output afterwards. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2616 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2617 close |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2618 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2619 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2620 Close the connection to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2621 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2622 flush |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2623 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2624 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2625 Flush data written to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2626 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2627 readavailable |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2628 ------------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2629 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2630 Read all available data from the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2631 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2632 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
|
2633 pipes and read available data. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2634 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2635 readline |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2636 -------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2637 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2638 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
|
2639 pipes, reads only the main pipe. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2640 """ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2641 opts = pycompat.byteskwargs(opts) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2642 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2643 if opts['localssh'] and not repo: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2644 raise error.Abort(_('--localssh requires a repository')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2645 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2646 if opts['peer'] and opts['peer'] not in ('raw', 'ssh1', 'ssh2'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2647 raise error.Abort(_('invalid value for --peer'), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2648 hint=_('valid values are "raw", "ssh1", and "ssh2"')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2649 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2650 if ui.interactive(): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2651 ui.write(_('(waiting for commands on stdin)\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2652 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2653 blocks = list(_parsewirelangblocks(ui.fin)) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2654 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2655 proc = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2656 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2657 if opts['localssh']: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2658 # 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
|
2659 # 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
|
2660 # shared state from interfering with server operation. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2661 args = util.hgcmd() + [ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2662 '-R', repo.root, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2663 'debugserve', '--sshstdio', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2664 ] |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2665 proc = subprocess.Popen(args, stdin=subprocess.PIPE, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2666 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2667 bufsize=0) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2668 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2669 stdin = proc.stdin |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2670 stdout = proc.stdout |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2671 stderr = proc.stderr |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2672 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2673 # We turn the pipes into observers so we can log I/O. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2674 if ui.verbose or opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2675 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2676 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2677 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2678 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2679 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2680 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2681 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2682 # --localssh also implies the peer connection settings. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2683 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2684 url = 'ssh://localserver' |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2685 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2686 if opts['peer'] == 'ssh1': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2687 ui.write(_('creating ssh peer for wire protocol version 1\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2688 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2689 None) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2690 elif opts['peer'] == 'ssh2': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2691 ui.write(_('creating ssh peer for wire protocol version 2\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2692 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2693 None) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2694 elif opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2695 ui.write(_('using raw connection to peer\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2696 peer = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2697 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2698 ui.write(_('creating ssh peer from handshake results\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2699 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2700 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2701 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2702 raise error.Abort(_('only --localssh is currently supported')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2703 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2704 # 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
|
2705 for action, lines in blocks: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2706 if action in ('raw', 'raw+'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2707 # Concatenate the data together. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2708 data = ''.join(l.lstrip() for l in lines) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2709 data = util.unescapestr(data) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2710 stdin.write(data) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2711 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2712 if action == 'raw+': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2713 stdin.flush() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2714 elif action == 'flush': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2715 stdin.flush() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2716 elif action == 'close': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2717 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2718 elif action == 'readavailable': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2719 fds = util.poll([stdout.fileno(), stderr.fileno()]) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2720 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2721 if stdout.fileno() in fds: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2722 util.readpipe(stdout) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2723 if stderr.fileno() in fds: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2724 util.readpipe(stderr) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2725 elif action == 'readline': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2726 stdout.readline() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2727 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2728 raise error.Abort(_('unknown action: %s') % action) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2729 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2730 if peer: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2731 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2732 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2733 if proc: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2734 proc.kill() |