Mercurial > hg-stable
annotate mercurial/debugcommands.py @ 38821:0a57945aaf7f
manifest: persist the manifestfulltext cache
Reconstructing the manifest from the revlog takes time, so much so that there
already is a LRU cache to avoid having to load a manifest multiple times.
This patch persists that LRU cache in the .hg/cache directory, so we can re-use
this cache across hg commands. Commit benchmark (run on Macos 10.13 on a
2017-model Macbook Pro with Core i7 2.9GHz and flash drive), testing without
and with patch run 5 times, baseline is r2a227782e754:
* committing to an existing file, against the mozilla-central repository.
Baseline real time average 1.9692, with patch 1.3786.
A new debugcommand "hg debugmanifestfulltextcache" lets you inspect the cache,
clear it, or add specific manifest nodeids to it. When calling
repo.updatecaches(), the manifest(s) for the working copy parents are added to
the cache.
The hg perfmanifest command has an additional --clear-disk switch to clear this
cache when testing manifest loading performance.
Using this command to test performance on the firefox repository for revision
f947d902ed91, whose manifest has a delta chain length of 60540, we see:
$ hg perfmanifest f947d902ed91 --clear-disk
! wall 0.972253 comb 0.970000 user 0.850000 sys 0.120000 (best of 10)
$ hg debugmanifestfulltextcache -a `hg log --debug -r f947d902ed91 | grep manifest | cut -d: -f3`
Cache contains 1 manifest entries, in order of most to least recent:
id: 0294517df4aad07c70701db43bc7ff24c3ce7dbc, size 25.6 MB
Total cache data size 25.6 MB, on-disk 0 bytes
$ hg perfmanifest f947d902ed91
! wall 0.036748 comb 0.040000 user 0.020000 sys 0.020000 (best of 100)
Worst-case scenario: a manifest text loaded from a single delta; in the firefox
repository manifest node 9a1246ff762e is the chain base for the manifest
attached to revision f947d902ed91. Loading this from a full cache file is just
as fast as without the cache; the extra node ids ensure a big full cache:
$ for node in 9a1246ff762e 1a1922c14a3e 54a31d11a36a 0294517df4aa; do
> hgd debugmanifestfulltextcache -a $node > /dev/null
> done
$ hgd perfmanifest -m 9a1246ff762e
! wall 0.077513 comb 0.080000 user 0.030000 sys 0.050000 (best of 100)
$ hgd perfmanifest -m 9a1246ff762e --clear-disk
! wall 0.078547 comb 0.080000 user 0.070000 sys 0.010000 (best of 100)
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Tue, 31 Jul 2018 19:37:54 +0200 |
parents | 6b5ca1d0aa1e |
children | e7aa113b14f7 |
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 |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
17 import re |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
18 import socket |
33493
9a9f95214f46
debug: add a method to check the state of, and built an SSL cert chain
Matt Harbison <matt_harbison@yahoo.com>
parents:
33438
diff
changeset
|
19 import ssl |
36789
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36786
diff
changeset
|
20 import stat |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
21 import string |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
22 import subprocess |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
23 import sys |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
24 import time |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 from .i18n import _ |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
27 from .node import ( |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
28 bin, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
29 hex, |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
30 nullhex, |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
31 nullid, |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
32 nullrev, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
33 short, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
34 ) |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
35 from .thirdparty import ( |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
36 cbor, |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
37 ) |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 from . import ( |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
39 bundle2, |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
40 changegroup, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 cmdutil, |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
42 color, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
43 context, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
44 dagparser, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
45 dagutil, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
46 encoding, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 error, |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
48 exchange, |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
49 extensions, |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
50 filemerge, |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
51 fileset, |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
52 formatter, |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
53 hg, |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
54 httppeer, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
55 localrepo, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
56 lock as lockmod, |
35928
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
57 logcmdutil, |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
58 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
|
59 obsolete, |
33148
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33119
diff
changeset
|
60 obsutil, |
32765
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
61 phases, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
62 policy, |
30967
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
63 pvec, |
30528
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30527
diff
changeset
|
64 pycompat, |
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32355
diff
changeset
|
65 registrar, |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
66 repair, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 revlog, |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
68 revset, |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
69 revsetlang, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 scmutil, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
71 setdiscovery, |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
72 simplemerge, |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
73 sshpeer, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
74 sslutil, |
30511
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30510
diff
changeset
|
75 streamclone, |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
76 templater, |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
77 treediscovery, |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31694
diff
changeset
|
78 upgrade, |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
79 url as urlmod, |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
80 util, |
31249
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31226
diff
changeset
|
81 vfs as vfsmod, |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
82 wireprotoframing, |
36556
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
83 wireprotoserver, |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
84 wireprotov2peer, |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 ) |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
86 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
87 dateutil, |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
88 procutil, |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
89 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
90 ) |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
92 release = lockmod.release |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
93 |
32416
c942c83ac2ec
debugcommands: use temporary dict for its command table
Yuya Nishihara <yuya@tcha.org>
parents:
32415
diff
changeset
|
94 command = registrar.command() |
30411
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 def debugancestor(ui, repo, *args): |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 """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
|
99 if len(args) == 3: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 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
|
101 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
|
102 lookup = r.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 elif len(args) == 2: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 if not repo: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 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
|
106 '(.hg not found)')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 rev1, rev2 = args |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 r = repo.changelog |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 lookup = repo.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 else: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 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
|
112 a = r.ancestor(lookup(rev1), lookup(rev2)) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 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
|
114 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
115 @command('debugapplystreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
116 def debugapplystreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
117 """apply a stream clone bundle file""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
118 f = hg.openpath(ui, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
119 gen = exchange.readbundle(ui, f, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
120 gen.apply(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
121 |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
122 @command('debugbuilddag', |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
123 [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
124 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
125 ('n', 'new-file', None, _('add new file at each rev'))], |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
126 _('[OPTION]... [TEXT]')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
127 def debugbuilddag(ui, repo, text=None, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
128 mergeable_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
129 overwritten_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
130 new_file=False): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
131 """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
|
132 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
133 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
|
134 command line. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
135 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
136 Elements: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
137 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
138 - "+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
|
139 - "." is a single node based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
140 - "$" resets the default parent to null (implied at the start); |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
141 otherwise the default parent is always the last node created |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
142 - "<p" sets the default parent to the backref p |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
143 - "*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
|
144 - "*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
|
145 - "/p2" is a merge of the preceding node and p2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
146 - ":tag" defines a local tag for the preceding node |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
147 - "@branch" sets the named branch for subsequent nodes |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
148 - "#...\\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
|
149 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
150 Whitespace between the above elements is ignored. |
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 A backref is either |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
153 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
154 - 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
|
155 node, or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
156 - 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
|
157 - empty to denote the default parent. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
158 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
159 All string valued-elements are either strictly alphanumeric, or must |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
160 be enclosed in double quotes ("..."), with "\\" as escape character. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
161 """ |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
162 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
163 if text is None: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
164 ui.status(_("reading DAG from stdin\n")) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
165 text = ui.fin.read() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
166 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
167 cl = repo.changelog |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
168 if len(cl) > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
169 raise error.Abort(_('repository is not empty')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
170 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
171 # determine number of revs in DAG |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
172 total = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
173 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
174 if type == 'n': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
175 total += 1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
176 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
177 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
178 linesperrev = 2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
179 # 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
|
180 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
|
181 initialmergedlines.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
182 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
183 tags = [] |
38381
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38361
diff
changeset
|
184 progress = ui.makeprogress(_('building'), unit=_('revisions'), |
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38361
diff
changeset
|
185 total=total) |
38382
0d7ec620faef
debugbuilddag: use context manager for progress, locks, transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
38381
diff
changeset
|
186 with progress, repo.wlock(), repo.lock(), repo.transaction("builddag"): |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
187 at = -1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
188 atbranch = 'default' |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
189 nodeids = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
190 id = 0 |
38381
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38361
diff
changeset
|
191 progress.update(id) |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
192 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
193 if type == 'n': |
35585
35fb3367f72d
py3: use pycompat.bytestr() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35562
diff
changeset
|
194 ui.note(('node %s\n' % pycompat.bytestr(data))) |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
195 id, ps = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
196 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
197 files = [] |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
198 filecontent = {} |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
199 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
200 p2 = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
201 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
202 fn = "mf" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
203 p1 = repo[ps[0]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
204 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
205 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
206 pa = p1.ancestor(p2) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
207 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
|
208 p2)] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
209 m3 = simplemerge.Merge3Text(base, local, other) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
210 ml = [l.strip() for l in m3.merge_lines()] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
211 ml.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
212 elif at > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
213 ml = p1[fn].data().split("\n") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
214 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
215 ml = initialmergedlines |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
216 ml[id * linesperrev] += " r%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
217 mergedtext = "\n".join(ml) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
218 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
219 filecontent[fn] = mergedtext |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
220 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
221 if overwritten_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
222 fn = "of" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
223 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
224 filecontent[fn] = "r%i\n" % id |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
225 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
226 if new_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
227 fn = "nf%i" % id |
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] = "r%i\n" % id |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
230 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
231 if not p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
232 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
233 for fn in p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
234 if fn.startswith("nf"): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
235 files.append(fn) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
236 filecontent[fn] = p2[fn].data() |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
237 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
238 def fctxfn(repo, cx, path): |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
239 if path in filecontent: |
35407
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35406
diff
changeset
|
240 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
|
241 filecontent[path]) |
35406
dffc35a5be9f
debugbuilddag: create filectx instance in 'filectxfn' callback
Martin von Zweigbergk <martinvonz@google.com>
parents:
35402
diff
changeset
|
242 return None |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
243 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
244 if len(ps) == 0 or ps[0] < 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
245 pars = [None, None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
246 elif len(ps) == 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
247 pars = [nodeids[ps[0]], None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
248 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
249 pars = [nodeids[p] for p in ps] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
250 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
251 date=(id, 0), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
252 user="debugbuilddag", |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
253 extra={'branch': atbranch}) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
254 nodeid = repo.commitctx(cx) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
255 nodeids.append(nodeid) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
256 at = id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
257 elif type == 'l': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
258 id, name = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
259 ui.note(('tag %s\n' % name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
260 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
|
261 elif type == 'a': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
262 ui.note(('branch %s\n' % data)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
263 atbranch = data |
38381
fce1c17493db
debugbuilddag: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38361
diff
changeset
|
264 progress.update(id) |
30412
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
265 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
266 if tags: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30411
diff
changeset
|
267 repo.vfs.write("localtags", "".join(tags)) |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
268 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
269 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
|
270 indent_string = ' ' * indent |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
271 if all: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
272 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
|
273 % indent_string) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
274 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
275 def showchunks(named): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
276 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
|
277 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
278 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
|
279 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
|
280 (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
|
281 hex(cs), hex(deltabase), len(delta))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
282 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
283 chunkdata = gen.changelogheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
284 showchunks("changelog") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
285 chunkdata = gen.manifestheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
286 showchunks("manifest") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
287 for chunkdata in iter(gen.filelogheader, {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
288 fname = chunkdata['filename'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
289 showchunks(fname) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
290 else: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
291 if isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
292 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
|
293 chunkdata = gen.changelogheader() |
34299
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
294 for deltadata in gen.deltaiter(): |
311f6ccf8f23
debug: update debugbundle to use new deltaiter api
Durham Goode <durham@fb.com>
parents:
34145
diff
changeset
|
295 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
|
296 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
|
297 |
33041
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
298 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
|
299 """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
|
300 opts = pycompat.byteskwargs(opts) |
33041
b482d80e041b
debugcommands: pass part, not read data, into _debugobsmarker()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
301 data = part.read() |
32550
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
302 indent_string = ' ' * indent |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
303 try: |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 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
|
308 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
309 else: |
35165
8f6641fa7c89
py3: use '%d' for integers rather than '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35082
diff
changeset
|
310 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
|
311 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
|
312 ui.write(msg) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 fm.startitem() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
317 fm.plain(indent_string) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
318 cmdutil.showmarker(fm, m) |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
319 fm.end() |
b62b2b373bce
debugbundle: display the content of obsmarkers parts
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32491
diff
changeset
|
320 |
33043
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
321 def _debugphaseheads(ui, data, indent=0): |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
322 """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
|
323 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
|
324 headsbyphase = phases.binarydecode(data) |
33043
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
325 for phase in phases.allphases: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
326 for head in headsbyphase[phase]: |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
327 ui.write(indent_string) |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
33041
diff
changeset
|
328 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
|
329 |
34043
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
330 def _quasirepr(thing): |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
331 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
|
332 return '{%s}' % ( |
626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
Augie Fackler <raf@durin42.com>
parents:
33553
diff
changeset
|
333 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
|
334 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
|
335 |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
336 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
|
337 """lists the contents of a bundle2""" |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
338 if not isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 continue |
37836
d618558e4e8b
debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents:
37823
diff
changeset
|
345 msg = '%s -- %s (mandatory: %r)\n' |
d618558e4e8b
debugbundle: also display if a part is mandatory or advisory
Boris Feld <boris.feld@octobus.net>
parents:
37823
diff
changeset
|
346 ui.write((msg % (part.type, _quasirepr(part.params), part.mandatory))) |
30510
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
347 if part.type == 'changegroup': |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
348 version = part.params.get('version', '01') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30412
diff
changeset
|
349 cg = changegroup.getunbundler(version, part, 'UN') |
36957
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
350 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
351 _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
|
352 if part.type == 'obsmarkers': |
36957
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
353 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
354 _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
|
355 if part.type == 'phase-heads': |
36957
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
356 if not ui.quiet: |
c92d1d3c58ee
debugbundle: do not display detailed part data in --quiet mode
Boris Feld <boris.feld@octobus.net>
parents:
36851
diff
changeset
|
357 _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
|
358 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
359 @command('debugbundle', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
360 [('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
|
361 ('', 'part-type', [], _('show only the named part type')), |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
362 ('', 'spec', None, _('print the bundlespec of the bundle'))], |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
363 _('FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
364 norepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
365 def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
366 """lists the contents of a bundle""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
367 with hg.openpath(ui, bundlepath) as f: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
368 if spec: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
369 spec = exchange.getbundlespec(ui, f) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
370 ui.write('%s\n' % spec) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
371 return |
30511
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30510
diff
changeset
|
372 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
373 gen = exchange.readbundle(ui, f, bundlepath) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
374 if isinstance(gen, bundle2.unbundle20): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
375 return _debugbundle2(ui, gen, all=all, **opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
376 _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
|
377 |
35015
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
378 @command('debugcapabilities', |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
379 [], _('PATH'), |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
380 norepo=True) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
381 def debugcapabilities(ui, path, **opts): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
382 """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
|
383 opts = pycompat.byteskwargs(opts) |
35015
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
384 peer = hg.peer(ui, opts, path) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
385 caps = peer.capabilities() |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
386 ui.write(('Main capabilities:\n')) |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
387 for c in sorted(caps): |
7ee2d859f720
debug: add a debugcapabilities commands
Boris Feld <boris.feld@octobus.net>
parents:
34645
diff
changeset
|
388 ui.write((' %s\n') % c) |
35016
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
389 b2caps = bundle2.bundle2caps(peer) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
390 if b2caps: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
391 ui.write(('Bundle2 capabilities:\n')) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
392 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
|
393 ui.write((' %s\n') % key) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
394 for v in values: |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
395 ui.write((' %s\n') % v) |
762ea8a1f5e7
debug: print parsed bundle2 capabilities with debugcapabilities
Boris Feld <boris.feld@octobus.net>
parents:
35015
diff
changeset
|
396 |
30512
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
397 @command('debugcheckstate', [], '') |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
398 def debugcheckstate(ui, repo): |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
399 """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
|
400 parent1, parent2 = repo.dirstate.parents() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
401 m1 = repo[parent1].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
402 m2 = repo[parent2].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
403 errors = 0 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
404 for f in repo.dirstate: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
405 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
406 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
|
407 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
|
408 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
409 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
|
410 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
|
411 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
412 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
|
413 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
|
414 (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
415 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
416 for f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
417 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
418 if state not in "nrm": |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
419 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
|
420 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
421 if errors: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30511
diff
changeset
|
422 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
|
423 raise error.Abort(error) |
30513
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30512
diff
changeset
|
424 |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
425 @command('debugcolor', |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
426 [('', '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
|
427 'hg debugcolor') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
428 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
|
429 """show available color, effects or style""" |
38449
a0c3d83d5f04
py3: use stringutil.pprint() to print NoneType
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38382
diff
changeset
|
430 ui.write(('color mode: %s\n') % stringutil.pprint(ui._colormode)) |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
431 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
|
432 return _debugdisplaystyle(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
433 else: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
434 return _debugdisplaycolor(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
435 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
436 def _debugdisplaycolor(ui): |
31136
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
437 ui = ui.copy() |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
438 ui._styles.clear() |
31694
57a22f699179
color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents:
31639
diff
changeset
|
439 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
|
440 ui._styles[effect] = effect |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
441 if ui._terminfoparams: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
442 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
|
443 if k.startswith('color.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
444 ui._styles[k] = k[6:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
445 elif k.startswith('terminfo.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
446 ui._styles[k] = k[9:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
447 ui.write(_('available colors:\n')) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
448 # 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
|
449 items = sorted(ui._styles.items(), |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
450 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
|
451 for colorname, label in items: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31135
diff
changeset
|
452 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
|
453 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
454 def _debugdisplaystyle(ui): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
455 ui.write(_('available style:\n')) |
37823
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
456 if not ui._styles: |
0e9ddab2bac2
debugcolor: fix crash by empty styles (issue5856)
Yuya Nishihara <yuya@tcha.org>
parents:
37722
diff
changeset
|
457 return |
31135
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
458 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
|
459 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
|
460 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
|
461 if effects: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
462 # 50 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
463 ui.write(': ') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
464 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
|
465 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
|
466 ui.write('\n') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31091
diff
changeset
|
467 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
468 @command('debugcreatestreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
469 def debugcreatestreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
470 """create a stream clone bundle file |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
471 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
472 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
|
473 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
|
474 """ |
32765
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
475 # 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
|
476 # 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
|
477 if phases.hassecret(repo): |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
478 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
|
479 'revisions)\n')) |
23734c0e361f
debugcommands: issue warning when repo has secret changesets (issue5589)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32714
diff
changeset
|
480 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
481 requirements, gen = streamclone.generatebundlev1(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
482 changegroup.writechunks(ui, gen, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
483 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
484 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
485 |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
486 @command('debugdag', |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
487 [('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
|
488 ('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
|
489 ('', 'dots', None, _('use dots for runs')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
490 ('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
|
491 _('[OPTION]... [FILE [REV]...]'), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
492 optionalrepo=True) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
493 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
|
494 """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
|
495 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
496 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
|
497 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
|
498 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
499 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
|
500 """ |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
501 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
|
502 dots = opts.get(r'dots') |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
503 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
|
504 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
|
505 file_) |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
506 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
|
507 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
508 for r in rlog: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
509 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
|
510 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
511 if r in revs: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
512 yield 'l', (r, "r%i" % r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
513 elif repo: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
514 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
|
515 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
|
516 branches = opts.get(r'branches') |
30523
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
517 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
518 labels = {} |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
519 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
|
520 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
|
521 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
522 b = "default" |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
523 for r in cl: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
524 if branches: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
525 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
|
526 if newb != b: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
527 yield 'a', newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
528 b = newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
529 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
|
530 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
531 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
532 ls = labels.get(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
533 if ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
534 for l in ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
535 yield 'l', (r, l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
536 else: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
537 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
|
538 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
539 for line in dagparser.dagtextlines(events(), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
540 addspaces=spaces, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
541 wraplabels=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
542 wrapannotations=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
543 wrapnonlinear=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
544 usedots=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
545 maxlinewidth=70): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
546 ui.write(line) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
547 ui.write("\n") |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
548 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
549 @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
|
550 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
|
551 """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
|
552 opts = pycompat.byteskwargs(opts) |
30524
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
553 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
|
554 if rev is not None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
555 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
556 file_, rev = None, file_ |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
557 elif rev is None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
558 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
559 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
|
560 try: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30550
diff
changeset
|
561 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
|
562 except KeyError: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30523
diff
changeset
|
563 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
|
564 |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
565 @command('debugdate', |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
566 [('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
|
567 _('[-e] DATE [RANGE]'), |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
568 norepo=True, optionalrepo=True) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
569 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
|
570 """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
|
571 if opts[r"extended"]: |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36616
diff
changeset
|
572 d = dateutil.parsedate(date, util.extendeddateformats) |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
573 else: |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36616
diff
changeset
|
574 d = dateutil.parsedate(date) |
36429
a24c57f1f5c3
py3: use '%d' for integers instead of '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36368
diff
changeset
|
575 ui.write(("internal: %d %d\n") % d) |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36616
diff
changeset
|
576 ui.write(("standard: %s\n") % dateutil.datestr(d)) |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
577 if range: |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36616
diff
changeset
|
578 m = dateutil.matchdate(range) |
30525
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
579 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
|
580 |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
581 @command('debugdeltachain', |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
582 cmdutil.debugrevlogopts + cmdutil.formatteropts, |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
583 _('-c|-m|FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
584 optionalrepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
585 def debugdeltachain(ui, repo, file_=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
586 """dump information about delta chains in a revlog |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
587 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
588 Output can be templatized. Available template keywords are: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
589 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
590 :``rev``: revision number |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
591 :``chainid``: delta chain identifier (numbered by unique base) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
592 :``chainlen``: delta chain length to this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
593 :``prevrev``: previous revision in delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
594 :``deltatype``: role of delta / how it was computed |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
595 :``compsize``: compressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
596 :``uncompsize``: uncompressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
597 :``chainsize``: total size of compressed revisions in chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
598 :``chainratio``: total chain size divided by uncompressed revision size |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
599 (new delta chains typically start at ratio 2.00) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
600 :``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
|
601 of this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
602 :``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
|
603 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
|
604 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
|
605 the delta chain for this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
606 :``extraratio``: extradist divided by chainsize; another representation of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
607 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
|
608 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
609 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
|
610 are available: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
611 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
612 :``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
|
613 (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
|
614 :``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
|
615 :``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
|
616 :``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
|
617 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
618 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
|
619 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
620 opts = pycompat.byteskwargs(opts) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
621 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
622 index = r.index |
38148
b17fa9041695
debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents:
38021
diff
changeset
|
623 start = r.start |
b17fa9041695
debugdeltachain: r.start and r.length can be retrieved outside the loop
Paul Morelle <paul.morelle@octobus.net>
parents:
38021
diff
changeset
|
624 length = r.length |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
625 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
|
626 withsparseread = getattr(r, '_withsparseread', False) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
627 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
628 def revinfo(rev): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
629 e = index[rev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
630 compsize = e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
631 uncompsize = e[2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
632 chainsize = 0 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
633 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
634 if generaldelta: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
635 if e[3] == e[5]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
636 deltatype = 'p1' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
637 elif e[3] == e[6]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
638 deltatype = 'p2' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
639 elif e[3] == rev - 1: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
640 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
641 elif e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
642 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
643 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
644 deltatype = 'other' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
645 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
646 if e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
647 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
648 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
649 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
650 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
651 chain = r._deltachain(rev)[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
652 for iterrev in chain: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
653 e = index[iterrev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
654 chainsize += e[1] |
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 return compsize, uncompsize, deltatype, chain, chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
657 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
658 fm = ui.formatter('debugdeltachain', opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
659 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
660 fm.plain(' rev chain# chainlen prev delta ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
661 '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
|
662 'extraratio') |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
663 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
|
664 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
|
665 fm.plain('\n') |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
666 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
667 chainbases = {} |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
668 for rev in r: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
669 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
670 chainbase = chain[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
671 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
|
672 basestart = start(chainbase) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
673 revstart = start(rev) |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
674 lineardist = revstart + comp - basestart |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
675 extradist = lineardist - chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
676 try: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
677 prevrev = chain[-2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
678 except IndexError: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
679 prevrev = -1 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
680 |
38646
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
681 if uncomp != 0: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
682 chainratio = float(chainsize) / float(uncomp) |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
683 else: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
684 chainratio = chainsize |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
685 |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
686 if chainsize != 0: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
687 extraratio = float(extradist) / float(chainsize) |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
688 else: |
93313f66b69b
debugdeltachain: avoid division by zero when a chain is empty
Paul Morelle <paul.morelle@octobus.net>
parents:
38613
diff
changeset
|
689 extraratio = extradist |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
690 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
691 fm.startitem() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
692 fm.write('rev chainid chainlen prevrev deltatype compsize ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
693 'uncompsize chainsize chainratio lindist extradist ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
694 'extraratio', |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
695 '%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
|
696 rev, chainid, len(chain), prevrev, deltatype, comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
697 uncomp, chainsize, chainratio, lineardist, extradist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
698 extraratio, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
699 rev=rev, chainid=chainid, chainlen=len(chain), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
700 prevrev=prevrev, deltatype=deltatype, compsize=comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
701 uncompsize=uncomp, chainsize=chainsize, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
702 chainratio=chainratio, lindist=lineardist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
703 extradist=extradist, extraratio=extraratio) |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
704 if withsparseread: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
705 readsize = 0 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
706 largestblock = 0 |
35728
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
707 srchunks = 0 |
22a877215ea1
debugdeltachain: cleanup the double call to _slicechunk
Paul Morelle <paul.morelle@octobus.net>
parents:
35678
diff
changeset
|
708 |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
709 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
|
710 srchunks += 1 |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
711 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
|
712 blksize = blkend - start(revschunk[0]) |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
713 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
714 readsize += blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
715 if largestblock < blksize: |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
716 largestblock = blksize |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
717 |
38647
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
718 if readsize: |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
719 readdensity = float(chainsize) / float(readsize) |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
720 else: |
0f4c2c70e26e
debugdeltachain: protect against 0 readsize
Boris Feld <boris.feld@octobus.net>
parents:
38646
diff
changeset
|
721 readdensity = 1 |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
722 |
35678
43154a76f392
debugdeltachain: display how many chunks would be read in sparse-read mode
Paul Morelle <paul.morelle@octobus.net>
parents:
35585
diff
changeset
|
723 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
|
724 ' %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
|
725 readsize, largestblock, readdensity, srchunks, |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
726 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
|
727 readdensity=readdensity, srchunks=srchunks) |
35082
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
728 |
5cbbef8d2a57
debugdeltachain: output information about sparse read if enabled
Paul Morelle <paul.morelle@octobus.net>
parents:
35016
diff
changeset
|
729 fm.plain('\n') |
30550
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
730 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
731 fm.end() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30538
diff
changeset
|
732 |
30974
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
733 @command('debugdirstate|debugstate', |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
734 [('', '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
|
735 ('', '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
|
736 _('[OPTION]...')) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
737 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
|
738 """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
|
739 |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
740 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
|
741 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
|
742 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
743 timestr = "" |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
744 if datesort: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
745 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
|
746 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
747 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
|
748 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
|
749 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
|
750 timestr = 'unset ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
751 elif nodates: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
752 timestr = 'set ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
753 else: |
35172
b45a9d121b53
py3: make sure the first argument of time.strftime() is str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35165
diff
changeset
|
754 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
|
755 time.localtime(ent[3])) |
35214
d4b108fdf423
py3: use encoding.strtolocal() to convert string to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35172
diff
changeset
|
756 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
|
757 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
|
758 mode = 'lnk' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
759 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30973
diff
changeset
|
760 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
|
761 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
|
762 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
|
763 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
|
764 |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
765 @command('debugdiscovery', |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
766 [('', 'old', None, _('use old-style discovery')), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
767 ('', 'nonheads', None, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
768 _('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
|
769 ('', '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
|
770 ] + cmdutil.remoteopts, |
35431
702e6d2642e7
debugdiscovery: correct and clean up command synopsis
Martin von Zweigbergk <martinvonz@google.com>
parents:
35426
diff
changeset
|
771 _('[--rev REV] [OTHER]')) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
772 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
773 """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
|
774 opts = pycompat.byteskwargs(opts) |
35424
2105bdd9462a
debugdiscovery: drop reference to invalid --branch option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35408
diff
changeset
|
775 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
|
776 remote = hg.peer(repo, opts, remoteurl) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
777 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
|
778 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
779 # make sure tests are repeatable |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
780 random.seed(12323) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
781 |
35313
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
782 def doit(pushedrevs, remoteheads, remote=remote): |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
783 if opts.get('old'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
784 if not util.safehasattr(remote, 'branches'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
785 # enable in-client legacy support |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
786 remote = localrepo.locallegacypeer(remote.local()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
787 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
788 force=True) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
789 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
790 if not opts.get('nonheads'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
791 ui.write(("unpruned common: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
792 " ".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
|
793 dag = dagutil.revlogdag(repo.changelog) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
794 all = dag.ancestorset(dag.internalizeall(common)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
795 common = dag.externalizeall(dag.headsetofconnecteds(all)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
796 else: |
35313
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
797 nodes = None |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
798 if pushedrevs: |
f77121b6bf1b
setdiscover: allow to ignore part of the local graph
Boris Feld <boris.feld@octobus.net>
parents:
35214
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 ancestorsof=nodes) |
30526
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
803 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
804 rheads = set(hds) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
805 lheads = set(repo.heads()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
806 ui.write(("common heads: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
807 " ".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
|
808 if lheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
809 ui.write(("local is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
810 elif rheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
811 ui.write(("remote is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
812 |
35426
fed2c040764e
debugdiscovery: drop reference to non-existent --remote-head option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35425
diff
changeset
|
813 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
|
814 localrevs = opts['rev'] |
c73d23cbb129
debugdiscovery: drop reference to non-existent --serverlog option
Martin von Zweigbergk <martinvonz@google.com>
parents:
35424
diff
changeset
|
815 doit(localrevs, remoterevs) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
816 |
35562
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
817 _chunksize = 4 << 10 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
818 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
819 @command('debugdownload', |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
820 [ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
821 ('o', 'output', '', _('path')), |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
822 ], |
35730
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
823 optionalrepo=True) |
05d415790761
debugdownload: read repository hgrc if there is one
Boris Feld <boris.feld@octobus.net>
parents:
35728
diff
changeset
|
824 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
|
825 """download a resource using Mercurial logic and config |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
826 """ |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
827 fh = urlmod.open(ui, url, output) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
828 |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
829 dest = ui |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
830 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
831 dest = open(output, "wb", _chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
832 try: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
833 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
834 while data: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
835 dest.write(data) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
836 data = fh.read(_chunksize) |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
837 finally: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
838 if output: |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
839 dest.close() |
6580cf751418
debug: add a 'debugdownload' command
Boris Feld <boris.feld@octobus.net>
parents:
35518
diff
changeset
|
840 |
38021
8ba0344f9fb1
debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents:
37986
diff
changeset
|
841 @command('debugextensions', cmdutil.formatteropts, [], optionalrepo=True) |
8ba0344f9fb1
debugextensions: process extensions loaded from the local repository too
Matt Harbison <matt_harbison@yahoo.com>
parents:
37986
diff
changeset
|
842 def debugextensions(ui, repo, **opts): |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
843 '''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
|
844 opts = pycompat.byteskwargs(opts) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
845 exts = extensions.extensions(ui) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
846 hgver = util.version() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
847 fm = ui.formatter('debugextensions', opts) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
848 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
|
849 isinternal = extensions.ismoduleinternal(extmod) |
31091
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31044
diff
changeset
|
850 extsource = pycompat.fsencode(extmod.__file__) |
30527
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
851 if isinternal: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
852 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
|
853 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
854 exttestedwith = getattr(extmod, 'testedwith', '').split() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
855 extbuglink = getattr(extmod, 'buglink', None) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
856 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
857 fm.startitem() |
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 if ui.quiet or ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
860 fm.write('name', '%s\n', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
861 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
862 fm.write('name', '%s', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
863 if isinternal or hgver in exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
864 fm.plain('\n') |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
865 elif not exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
866 fm.plain(_(' (untested!)\n')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
867 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
868 lasttestedversion = exttestedwith[-1] |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
869 fm.plain(' (%s!)\n' % lasttestedversion) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
870 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
871 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
|
872 _(' location: %s\n'), extsource or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
873 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
874 if ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
875 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
|
876 fm.data(bundled=isinternal) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
877 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
878 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
|
879 _(' tested with: %s\n'), |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
880 fm.formatlist(exttestedwith, name='ver')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
881 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
882 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
|
883 _(' bug reporting: %s\n'), extbuglink or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
884 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
885 fm.end() |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
886 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
887 @command('debugfileset', |
38611
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
888 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
889 ('', 'all-files', False, |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
890 _('test files from all revisions and working directory'))], |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
891 _('[-r REV] [--all-files] FILESPEC')) |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
892 def debugfileset(ui, repo, expr, **opts): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
893 '''parse and apply a fileset specification''' |
38611
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
894 opts = pycompat.byteskwargs(opts) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
895 ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
896 if ui.verbose: |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
897 tree = fileset.parse(expr) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
898 ui.note(fileset.prettyformat(tree), "\n") |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
899 |
38611
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
900 files = set() |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
901 if opts['all_files']: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
902 for r in repo: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
903 c = repo[r] |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
904 files.update(c.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
905 files.update(c.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
906 if opts['all_files'] or ctx.rev() is None: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
907 wctx = repo[None] |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
908 files.update(repo.dirstate.walk(scmutil.matchall(repo), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
909 subrepos=list(wctx.substate), |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
910 unknown=True, ignored=True)) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
911 files.update(wctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
912 else: |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
913 files.update(ctx.files()) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
914 files.update(ctx.substate) |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
915 |
38613
760cc5dc01e8
fileset: restrict getfileset() to not return a computed set (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38611
diff
changeset
|
916 m = ctx.matchfileset(expr) |
38611
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
917 for f in sorted(files): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
918 if not m(f): |
3d8ef60569d8
fileset: make debugfileset filter repository files
Yuya Nishihara <yuya@tcha.org>
parents:
38600
diff
changeset
|
919 continue |
30533
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30528
diff
changeset
|
920 ui.write("%s\n" % f) |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
921 |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
922 @command('debugformat', |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
923 [] + cmdutil.formatteropts, |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
924 _('')) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
925 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
|
926 """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
|
927 |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
928 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
|
929 Mercurial default.""" |
35408
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35407
diff
changeset
|
930 opts = pycompat.byteskwargs(opts) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
931 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
|
932 maxvariantlength = max(len('format-variant'), maxvariantlength) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
933 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
934 def makeformatname(name): |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
935 return '%s:' + (' ' * (maxvariantlength - len(name))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
936 |
35387
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
937 fm = ui.formatter('debugformat', opts) |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
938 if fm.isplain(): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
939 def formatvalue(value): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
940 if util.safehasattr(value, 'startswith'): |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
941 return value |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
942 if value: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
943 return 'yes' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
944 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
945 return 'no' |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
946 else: |
9144e898cad5
debugformat: embed raw values in JSON and template output
Yuya Nishihara <yuya@tcha.org>
parents:
35386
diff
changeset
|
947 formatvalue = pycompat.identity |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
948 |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
949 fm.plain('format-variant') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
950 fm.plain(' ' * (maxvariantlength - len('format-variant'))) |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
951 fm.plain(' repo') |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
952 if ui.verbose: |
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
953 fm.plain(' config default') |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
954 fm.plain('\n') |
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
955 for fv in upgrade.allformatvariant: |
35386
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35348
diff
changeset
|
956 fm.startitem() |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
957 repovalue = fv.fromrepo(repo) |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
958 configvalue = fv.fromconfig(repo) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
959 |
35347
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
960 if repovalue != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
961 namelabel = 'formatvariant.name.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
962 repolabel = 'formatvariant.repo.mismatchconfig' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
963 elif repovalue != fv.default: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
964 namelabel = 'formatvariant.name.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
965 repolabel = 'formatvariant.repo.mismatchdefault' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
966 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
967 namelabel = 'formatvariant.name.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
968 repolabel = 'formatvariant.repo.uptodate' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
969 |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
970 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
|
971 label=namelabel) |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
972 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
|
973 label=repolabel) |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
974 if fv.default != configvalue: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
975 configlabel = 'formatvariant.config.special' |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
976 else: |
bd326f3e0e14
debugformat: update label depending on value difference
Boris Feld <boris.feld@octobus.net>
parents:
35346
diff
changeset
|
977 configlabel = 'formatvariant.config.default' |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
978 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
|
979 label=configlabel) |
35346
cfb403b92f43
debugformat: add data about the config when verbose
Boris Feld <boris.feld@octobus.net>
parents:
35345
diff
changeset
|
980 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
|
981 label='formatvariant.default') |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
982 fm.plain('\n') |
35386
c0b6fa74e007
debugformat: flush formatter output per item
Yuya Nishihara <yuya@tcha.org>
parents:
35348
diff
changeset
|
983 fm.end() |
35345
c3e4f196b6e0
debugformat: add a 'debugformat' command
Boris Feld <boris.feld@octobus.net>
parents:
35313
diff
changeset
|
984 |
30534
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
985 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
986 def debugfsinfo(ui, path="."): |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30533
diff
changeset
|
987 """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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 casesensitive = '(unknown)' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
995 try: |
38199
cc9aa88792fe
py3: wrap tempfile.NamedTemporaryFile() to return bytes fp.name
Yuya Nishihara <yuya@tcha.org>
parents:
38197
diff
changeset
|
996 with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: |
31639
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
997 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
998 except OSError: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
999 pass |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31638
diff
changeset
|
1000 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
|
1001 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1002 @command('debuggetbundle', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1003 [('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
|
1004 ('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
|
1005 ('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
|
1006 _('REPO FILE [-H|-C ID]...'), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1007 norepo=True) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1008 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
|
1009 """retrieves a bundle from a repo |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1010 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1011 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
|
1012 given file. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1013 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1014 opts = pycompat.byteskwargs(opts) |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1015 repo = hg.peer(ui, opts, repopath) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1016 if not repo.capable('getbundle'): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1017 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
|
1018 args = {} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1019 if common: |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1020 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
|
1021 if head: |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1022 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
|
1023 # 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
|
1024 args[r'bundlecaps'] = None |
30535
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1025 bundle = repo.getbundle('debug', **args) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1026 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1027 bundletype = opts.get('type', 'bzip2').lower() |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1028 btypes = {'none': 'HG10UN', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1029 'bzip2': 'HG10BZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1030 'gzip': 'HG10GZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1031 'bundle2': 'HG20'} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1032 bundletype = btypes.get(bundletype) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1033 if bundletype not in bundle2.bundletypes: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30534
diff
changeset
|
1034 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
|
1035 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
|
1036 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1037 @command('debugignore', [], '[FILE]') |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1038 def debugignore(ui, repo, *files, **opts): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1039 """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
|
1040 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1041 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
|
1042 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1043 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
|
1044 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
|
1045 """ |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1046 ignore = repo.dirstate._ignore |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1047 if not files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1048 # Show all the patterns |
36607
149fd142f498
debugcommands: fix repr in debugignore print with pycompat.bytestr
Augie Fackler <augie@google.com>
parents:
36563
diff
changeset
|
1049 ui.write("%s\n" % pycompat.byterepr(ignore)) |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1050 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1051 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
|
1052 for f in m.files(): |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1053 nf = util.normpath(f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1054 ignored = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1055 ignoredata = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1056 if nf != '.': |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1057 if ignore(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1058 ignored = nf |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1059 ignoredata = repo.dirstate._ignorefileandline(nf) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1060 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1061 for p in util.finddirs(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1062 if ignore(p): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1063 ignored = p |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1064 ignoredata = repo.dirstate._ignorefileandline(p) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1065 break |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1066 if ignored: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1067 if ignored == nf: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1068 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
|
1069 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1070 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
|
1071 "containing folder %s\n") |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1072 % (m.uipath(f), ignored)) |
30536
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1073 ignorefile, lineno, line = ignoredata |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1074 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
|
1075 % (ignorefile, lineno, line)) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30535
diff
changeset
|
1076 else: |
33507
e9672de52a23
debugignore: eliminate inconsistencies with `hg status` (issue5222)
Matt Harbison <matt_harbison@yahoo.com>
parents:
33493
diff
changeset
|
1077 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
|
1078 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1079 @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
|
1080 [('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
|
1081 _('[-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
|
1082 optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1083 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
|
1084 """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
|
1085 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
|
1086 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
|
1087 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
|
1088 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
|
1089 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
|
1090 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1091 if ui.debugflag: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1092 shortfn = hex |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1093 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1094 shortfn = short |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1095 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1096 # 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
|
1097 idlen = 12 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1098 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1099 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
|
1100 break |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1101 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1102 if format == 0: |
37285
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1103 if ui.verbose: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1104 ui.write((" rev offset length linkrev" |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1105 " %s %s p2\n") % ("nodeid".ljust(idlen), |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1106 "p1".ljust(idlen))) |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1107 else: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1108 ui.write((" rev linkrev %s %s p2\n") % ( |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1109 "nodeid".ljust(idlen), "p1".ljust(idlen))) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1110 elif format == 1: |
37285
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1111 if ui.verbose: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1112 ui.write((" rev flag offset length size link p1" |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1113 " p2 %s\n") % "nodeid".rjust(idlen)) |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1114 else: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1115 ui.write((" rev flag size link p1 p2 %s\n") % |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1116 "nodeid".rjust(idlen)) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1117 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1118 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1119 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1120 if format == 0: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1121 try: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1122 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1123 except Exception: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1124 pp = [nullid, nullid] |
37285
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1125 if ui.verbose: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1126 ui.write("% 6d % 9d % 7d % 7d %s %s %s\n" % ( |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1127 i, r.start(i), r.length(i), r.linkrev(i), |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1128 shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1129 else: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1130 ui.write("% 6d % 7d %s %s %s\n" % ( |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1131 i, r.linkrev(i), shortfn(node), shortfn(pp[0]), |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1132 shortfn(pp[1]))) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1133 elif format == 1: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1134 pr = r.parentrevs(i) |
37285
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1135 if ui.verbose: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1136 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d %s\n" % ( |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1137 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1138 r.linkrev(i), pr[0], pr[1], shortfn(node))) |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1139 else: |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1140 ui.write("% 6d %04x % 8d % 6d % 6d % 6d %s\n" % ( |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1141 i, r.flags(i), r.rawsize(i), r.linkrev(i), pr[0], pr[1], |
d4e62df1c73d
debugcommands: drop offset and length from debugindex by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37284
diff
changeset
|
1142 shortfn(node))) |
30537
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1143 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1144 @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
|
1145 _('-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
|
1146 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
|
1147 """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
|
1148 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
|
1149 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
|
1150 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
|
1151 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1152 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1153 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1154 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
|
1155 if pp[1] != nullid: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30536
diff
changeset
|
1156 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
|
1157 ui.write("}\n") |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
1158 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
1159 @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
|
1160 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
|
1161 '''test Mercurial installation |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1162 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1163 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
|
1164 ''' |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1165 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
|
1166 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1167 def writetemp(contents): |
38197
aac4be30e250
py3: wrap tempfile.mkstemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
38148
diff
changeset
|
1168 (fd, name) = pycompat.mkstemp(prefix="hg-debuginstall-") |
36843
5bc7ff103081
py3: use r'' instead of sysstr('') to get around code transformer
Yuya Nishihara <yuya@tcha.org>
parents:
36800
diff
changeset
|
1169 f = os.fdopen(fd, r"wb") |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1170 f.write(contents) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1171 f.close() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1172 return name |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1173 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1174 problems = 0 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1175 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1176 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
|
1177 fm.startitem() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1178 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1179 # encoding |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1180 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
|
1181 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1182 try: |
34144
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34135
diff
changeset
|
1183 codecs.lookup(pycompat.sysstr(encoding.encoding)) |
902219a99901
debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara <yuya@tcha.org>
parents:
34135
diff
changeset
|
1184 except LookupError as inst: |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1185 err = stringutil.forcebytestr(inst) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1186 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1187 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
|
1188 " (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
|
1189 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1190 # Python |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1191 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
|
1192 pycompat.sysexecutable) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1193 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
|
1194 ("%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
|
1195 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
|
1196 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
|
1197 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1198 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
|
1199 if sslutil.hassni: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1200 security.add('sni') |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1201 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1202 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
|
1203 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
|
1204 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 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1206 # 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
|
1207 # 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
|
1208 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
|
1209 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
|
1210 '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
|
1211 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
|
1212 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
|
1213 '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
|
1214 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1215 # 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
|
1216 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1217 # hg version |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1218 hgver = util.version() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1219 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
|
1220 hgver.split('+')[0]) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1221 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
|
1222 '+'.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
|
1223 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1224 # compiled modules |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1225 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
|
1226 policy.policy) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1227 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
|
1228 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
|
1229 |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1230 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
|
1231 err = None |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1232 try: |
32406
a9c71d578a1c
osutil: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32402
diff
changeset
|
1233 from .cext import ( |
32407
008d37c4d783
base85: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32406
diff
changeset
|
1234 base85, |
32408
3b88a7fa97d8
bdiff: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32407
diff
changeset
|
1235 bdiff, |
32410
151cc3b3d799
mpatch: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32408
diff
changeset
|
1236 mpatch, |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1237 osutil, |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1238 ) |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1239 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
|
1240 except Exception as inst: |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1241 err = stringutil.forcebytestr(inst) |
32249
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1242 problems += 1 |
85dc5a25f1fc
debuginstall: check C extensions only if they are loadable per policy
Yuya Nishihara <yuya@tcha.org>
parents:
31864
diff
changeset
|
1243 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
|
1244 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1245 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
|
1246 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
|
1247 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
|
1248 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
|
1249 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
|
1250 '(%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1251 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
|
1252 if e.available()), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1253 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
|
1254 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
|
1255 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
|
1256 '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
|
1257 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
|
1258 if e.wireprotosupport()], |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1259 name='compengine', fmt='%s', sep=', ')) |
35452
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1260 re2 = 'missing' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1261 if util._re2: |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1262 re2 = 'available' |
8251c4c4abdc
debuginstall: add a line about re2 availability
Boris Feld <boris.feld@octobus.net>
parents:
35431
diff
changeset
|
1263 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
|
1264 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
|
1265 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1266 # templates |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1267 p = templater.templatepaths() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1268 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
|
1269 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
|
1270 if p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1271 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
|
1272 if m: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1273 # 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
|
1274 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1275 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1276 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
|
1277 except Exception as inst: |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1278 err = stringutil.forcebytestr(inst) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1279 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1280 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
|
1281 else: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1282 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1283 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
|
1284 _("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
|
1285 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
|
1286 _(" 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
|
1287 if not p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1288 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1289 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
|
1290 _(" (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
|
1291 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1292 # editor |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1293 editor = ui.geteditor() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1294 editor = util.expandpath(editor) |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
1295 editorbin = procutil.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
|
1296 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
1297 cmdpath = procutil.findexe(editorbin) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1298 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
|
1299 _(" 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
|
1300 " (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
|
1301 " 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
|
1302 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
|
1303 _(" 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
|
1304 " (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
|
1305 " 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
|
1306 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
|
1307 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1308 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1309 # check username |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1310 username = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1311 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1312 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1313 username = ui.username() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1314 except error.Abort as e: |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1315 err = stringutil.forcebytestr(e) |
30938
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1316 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1317 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1318 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
|
1319 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
|
1320 " (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
|
1321 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1322 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
|
1323 _("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
|
1324 if not problems: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1325 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
|
1326 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
|
1327 _("%d problems detected," |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1328 " 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
|
1329 fm.end() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1330 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1331 return problems |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1332 |
30939
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1333 @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
|
1334 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
|
1335 """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
|
1336 |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1337 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
|
1338 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
|
1339 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1340 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
|
1341 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
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 |
30955
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1347 @command('debuglabelcomplete', [], _('LABEL...')) |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1348 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
|
1349 '''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
|
1350 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
|
1351 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1352 @command('debuglocks', |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1353 [('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
|
1354 ('W', 'force-wlock', None, |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1355 _('free the working state lock (DANGEROUS)')), |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1356 ('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
|
1357 ('S', 'set-wlock', None, |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1358 _('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
|
1359 _('[OPTION]...')) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1360 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
|
1361 """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
|
1362 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1363 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
|
1364 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
|
1365 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
|
1366 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
|
1367 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1373 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
|
1374 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
|
1375 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
|
1376 |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1377 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
|
1378 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
|
1379 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
|
1380 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1381 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
|
1382 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1383 """ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1384 |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1385 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
|
1386 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
|
1387 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
|
1388 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
|
1389 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
|
1390 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1391 |
35402
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1392 locks = [] |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1393 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1394 if opts.get(r'set_wlock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1395 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1396 locks.append(repo.wlock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1397 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1398 raise error.Abort(_('wlock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1399 if opts.get(r'set_lock'): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1400 try: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1401 locks.append(repo.lock(False)) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1402 except error.LockHeld: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1403 raise error.Abort(_('lock is already held')) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1404 if len(locks): |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1405 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
|
1406 return 0 |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1407 finally: |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1408 release(*locks) |
12055fb3ba30
debuglocks: allow setting a lock
Paul Morelle <paul.morelle@octobus.net>
parents:
35401
diff
changeset
|
1409 |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1410 now = time.time() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1411 held = 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1412 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1413 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
|
1414 # 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
|
1415 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1416 l = method(False) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1417 except error.LockHeld: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1418 l = None |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1419 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1420 if l: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1421 l.release() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1422 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1423 try: |
36789
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36786
diff
changeset
|
1424 st = vfs.lstat(name) |
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36786
diff
changeset
|
1425 age = now - st[stat.ST_MTIME] |
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36786
diff
changeset
|
1426 user = util.username(st.st_uid) |
30958
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1427 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
|
1428 if ":" in locker: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1429 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
|
1430 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
|
1431 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
|
1432 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1433 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
|
1434 % (user, pid, host) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1435 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
|
1436 return 1 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1437 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
|
1438 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
|
1439 raise |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1440 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1441 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
|
1442 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1443 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1444 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
|
1445 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
|
1446 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1447 return held |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
1448 |
38821
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1449 @command('debugmanifestfulltextcache', [ |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1450 ('', 'clear', False, _('clear the cache')), |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1451 ('a', 'add', '', _('add the given manifest node to the cache'), |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1452 _('NODE')) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1453 ], '') |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1454 def debugmanifestfulltextcache(ui, repo, add=None, **opts): |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1455 """show, clear or amend the contents of the manifest fulltext cache""" |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1456 with repo.lock(): |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1457 r = repo.manifestlog._revlog |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1458 try: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1459 cache = r._fulltextcache |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1460 except AttributeError: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1461 ui.warn(_( |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1462 "Current revlog implementation doesn't appear to have a " |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1463 'manifest fulltext cache\n')) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1464 return |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1465 |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1466 if opts.get(r'clear'): |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1467 cache.clear() |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1468 |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1469 if add: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1470 try: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1471 manifest = repo.manifestlog[r.lookup(add)] |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1472 except error.LookupError as e: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1473 raise error.Abort(e, hint="Check your manifest node id") |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1474 manifest.read() # stores revisision in cache too |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1475 |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1476 if not len(cache): |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1477 ui.write(_('Cache empty')) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1478 else: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1479 ui.write( |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1480 _('Cache contains %d manifest entries, in order of most to ' |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1481 'least recent:\n') % (len(cache),)) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1482 totalsize = 0 |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1483 for nodeid in cache: |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1484 # Use cache.get to not update the LRU order |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1485 data = cache.get(nodeid) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1486 size = len(data) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1487 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1488 ui.write(_('id: %s, size %s\n') % ( |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1489 hex(nodeid), util.bytecount(size))) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1490 ondisk = cache._opener.stat('manifestfulltextcache').st_size |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1491 ui.write( |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1492 _('Total cache data size %s, on-disk %s\n') % ( |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1493 util.bytecount(totalsize), util.bytecount(ondisk)) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1494 ) |
0a57945aaf7f
manifest: persist the manifestfulltext cache
Martijn Pieters <mj@zopatista.com>
parents:
38707
diff
changeset
|
1495 |
30956
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1496 @command('debugmergestate', [], '') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1497 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
|
1498 """print merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1499 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1500 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
|
1501 was chosen.""" |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1502 def _hashornull(h): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1503 if h == nullhex: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1504 return 'null' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1505 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1506 return h |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1507 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1508 def printrecords(version): |
36191
72d155a792b1
debugcommands: mergestate version is an int, use %d on it
Augie Fackler <augie@google.com>
parents:
36161
diff
changeset
|
1509 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
|
1510 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1511 records = v1records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1512 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1513 records = v2records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1514 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1515 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
|
1516 # 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
|
1517 if rtype == 'L': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1518 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
|
1519 elif rtype == 'O': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1520 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
|
1521 elif rtype == 'm': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1522 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
|
1523 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
|
1524 % (driver, mdstate)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1525 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
|
1526 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
|
1527 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
|
1528 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1529 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
|
1530 flags = r[7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1531 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1532 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
|
1533 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
|
1534 % (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
|
1535 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
|
1536 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
|
1537 % (afile, _hashornull(anode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1538 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
|
1539 % (ofile, _hashornull(onode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1540 elif rtype == 'f': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1541 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
|
1542 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
|
1543 i = 0 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1544 extrastrings = [] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1545 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
|
1546 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
|
1547 i += 2 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1548 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1549 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
|
1550 % (filename, ', '.join(extrastrings))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1551 elif rtype == 'l': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1552 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
|
1553 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
|
1554 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
|
1555 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
|
1556 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
|
1557 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
|
1558 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
|
1559 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1560 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
|
1561 % (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
|
1562 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1563 # 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
|
1564 # 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
|
1565 # 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
|
1566 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
|
1567 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1568 # 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
|
1569 v1records = ms._readrecordsv1() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1570 v2records = ms._readrecordsv2() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1571 order = 'LOml' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1572 def key(r): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1573 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
|
1574 if idx == -1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1575 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
|
1576 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1577 return (0, idx) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1578 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
|
1579 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
|
1580 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1581 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
|
1582 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
|
1583 elif not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1584 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
|
1585 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1586 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
|
1587 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
|
1588 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1589 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1590 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
|
1591 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1592 if ui.verbose: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1593 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1594 |
30957
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1595 @command('debugnamecomplete', [], _('NAME...')) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1596 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
|
1597 '''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
|
1598 |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1599 names = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1600 # 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
|
1601 # 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
|
1602 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
|
1603 if name != 'branches': |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1604 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
|
1605 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
|
1606 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
|
1607 completions = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1608 if not args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1609 args = [''] |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1610 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
|
1611 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
|
1612 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
|
1613 ui.write('\n') |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
1614 |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1615 @command('debugobsolete', |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1616 [('', '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
|
1617 ('', 'record-parents', False, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1618 _('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
|
1619 ('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
|
1620 ('', '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
|
1621 '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
|
1622 ('', '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
|
1623 ('', '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
|
1624 ] + 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
|
1625 _('[OBSOLETED [REPLACEMENT ...]]')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1626 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
|
1627 """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
|
1628 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1629 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
|
1630 |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1631 opts = pycompat.byteskwargs(opts) |
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1632 |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1633 def parsenodeid(s): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1634 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1635 # 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
|
1636 # 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
|
1637 # local repository. |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1638 n = bin(s) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1639 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
|
1640 raise TypeError() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1641 return n |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1642 except TypeError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1643 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
|
1644 'node identifiers') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1645 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1646 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
|
1647 indices = [] |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1648 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
|
1649 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1650 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
|
1651 except ValueError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1652 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
|
1653 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
|
1654 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1655 if repo.currenttransaction(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1656 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
|
1657 'of transaction.')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1658 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1659 with repo.lock(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1660 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
|
1661 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
|
1662 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1663 return |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1664 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1665 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
|
1666 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1667 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
|
1668 metadata = {} |
38707
6b5ca1d0aa1e
obsolete: store user name and note in UTF-8 (issue5754) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38647
diff
changeset
|
1669 metadata['user'] = encoding.fromlocal(opts['user'] or ui.username()) |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1670 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
|
1671 l = repo.lock() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1672 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1673 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
|
1674 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1675 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
|
1676 if date: |
36636
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36616
diff
changeset
|
1677 date = dateutil.parsedate(date) |
30959
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1678 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1679 date = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1680 prec = parsenodeid(precursor) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1681 parents = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1682 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
|
1683 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
|
1684 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
|
1685 'unknown changesets') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1686 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
|
1687 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
|
1688 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
|
1689 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
|
1690 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
|
1691 tr.close() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1692 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
|
1693 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
|
1694 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
|
1695 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1696 tr.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1697 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1698 l.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1699 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1700 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1701 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
|
1702 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
|
1703 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
|
1704 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
|
1705 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
|
1706 else: |
33155
a14e2e7f7d1f
obsutil: move 'getmarkers' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33154
diff
changeset
|
1707 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
|
1708 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1709 markerstoiter = markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1710 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
|
1711 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
|
1712 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
|
1713 markerset = set(markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1714 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
|
1715 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1716 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
|
1717 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
|
1718 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
|
1719 # 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
|
1720 # 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
|
1721 # 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
|
1722 # 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
|
1723 # 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
|
1724 # 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
|
1725 # 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
|
1726 continue |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1727 fm.startitem() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1728 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
|
1729 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
|
1730 fm.end() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
1731 |
30960
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1732 @command('debugpathcomplete', |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1733 [('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
|
1734 ('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
|
1735 ('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
|
1736 ('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
|
1737 _('FILESPEC...')) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1738 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
|
1739 '''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
|
1740 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1741 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
|
1742 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
|
1743 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1744 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
|
1745 --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
|
1746 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1747 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
|
1748 dirstate = repo.dirstate |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1749 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
|
1750 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
|
1751 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
|
1752 return [], [] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1753 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
|
1754 spec += '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1755 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
|
1756 fixpaths = pycompat.ossep != '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1757 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1758 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
|
1759 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
|
1760 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
|
1761 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
|
1762 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
|
1763 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
|
1764 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
|
1765 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1766 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
|
1767 if fullpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1768 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1769 continue |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1770 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
|
1771 if s >= 0: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1772 adddir(f[:s]) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1773 else: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1774 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1775 return files, dirs |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1776 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1777 acceptable = '' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1778 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
|
1779 acceptable += 'nm' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1780 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
|
1781 acceptable += 'a' |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
1782 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
|
1783 acceptable += 'r' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1784 cwd = repo.getcwd() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1785 if not specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1786 specs = ['.'] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1787 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1788 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
|
1789 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
|
1790 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
|
1791 files.update(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1792 dirs.update(d) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1793 files.update(dirs) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1794 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
|
1795 ui.write('\n') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30959
diff
changeset
|
1796 |
35969
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1797 @command('debugpeer', [], _('PATH'), norepo=True) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1798 def debugpeer(ui, path): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1799 """establish a connection to a peer repository""" |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1800 # Always enable peer request logging. Requires --debug to display |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1801 # though. |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1802 overrides = { |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1803 ('devel', 'debug.peer-request'): True, |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1804 } |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1805 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1806 with ui.configoverride(overrides): |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1807 peer = hg.peer(ui, {}, path) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1808 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1809 local = peer.local() is not None |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1810 canpush = peer.canpush() |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1811 |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1812 ui.write(_('url: %s\n') % peer.url()) |
5f029d03cf71
debugcommands: introduce debugpeer command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35942
diff
changeset
|
1813 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
|
1814 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
|
1815 |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1816 @command('debugpickmergetool', |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1817 [('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
|
1818 ('', '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
|
1819 ] + 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
|
1820 _('[PATTERN]...'), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1821 inferrepo=True) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1822 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
|
1823 """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
|
1824 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1825 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
|
1826 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
|
1827 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
|
1828 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1829 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
|
1830 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
|
1831 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
|
1832 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
|
1833 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
|
1834 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
|
1835 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
|
1836 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1837 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
|
1838 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1839 FILE = MERGETOOL |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1840 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1841 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
|
1842 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
|
1843 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
|
1844 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
|
1845 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1846 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
|
1847 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
|
1848 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
|
1849 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
|
1850 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
|
1851 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1852 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
|
1853 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
|
1854 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1855 - ``--tool`` option |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1856 - ``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
|
1857 - 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
|
1858 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1859 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
|
1860 ``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
|
1861 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
|
1862 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
|
1863 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1864 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
|
1865 overrides = {} |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1866 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
|
1867 overrides[('ui', 'forcemerge')] = opts['tool'] |
36786
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36764
diff
changeset
|
1868 ui.note(('with --tool %r\n') % (pycompat.bytestr(opts['tool']))) |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1869 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1870 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
|
1871 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
|
1872 if hgmerge is not None: |
36786
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36764
diff
changeset
|
1873 ui.note(('with HGMERGE=%r\n') % (pycompat.bytestr(hgmerge))) |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1874 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
|
1875 if uimerge: |
36786
7aae39d03139
debugcommands: fix some %r output with bytestr() wrappers
Augie Fackler <augie@google.com>
parents:
36764
diff
changeset
|
1876 ui.note(('with ui.merge=%r\n') % (pycompat.bytestr(uimerge))) |
32296
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1877 |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1878 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
|
1879 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
|
1880 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
|
1881 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
|
1882 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
|
1883 try: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1884 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
|
1885 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
|
1886 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
|
1887 fctx.isbinary(), |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1888 '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
|
1889 changedelete) |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1890 finally: |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1891 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
|
1892 ui.popbuffer() |
9bc36198338e
debugcommands: add debugpickmergetool to examine which merge tool is chosen
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32269
diff
changeset
|
1893 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
|
1894 |
30966
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1895 @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
|
1896 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
|
1897 '''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
|
1898 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1899 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
|
1900 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1901 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
|
1902 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
|
1903 ''' |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1904 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1905 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
|
1906 if keyinfo: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1907 key, old, new = keyinfo |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1908 with target.commandexecutor() as e: |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1909 r = e.callcommand('pushkey', { |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1910 'namespace': namespace, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1911 'key': key, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1912 'old': old, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1913 'new': new, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1914 }).result() |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37645
diff
changeset
|
1915 |
36742
390d16ea7c76
py3: use pycompat.bytestr instead of str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36636
diff
changeset
|
1916 ui.status(pycompat.bytestr(r) + '\n') |
30966
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1917 return not r |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1918 else: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1919 for k, v in sorted(target.listkeys(namespace).iteritems()): |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1920 ui.write("%s\t%s\n" % (stringutil.escapestr(k), |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
1921 stringutil.escapestr(v))) |
30966
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30960
diff
changeset
|
1922 |
30967
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1923 @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
|
1924 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
|
1925 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
|
1926 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
|
1927 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
|
1928 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
|
1929 if pa == pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1930 rel = "=" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1931 elif pa > pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1932 rel = ">" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1933 elif pa < pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1934 rel = "<" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1935 elif pa | pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1936 rel = "|" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30966
diff
changeset
|
1937 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
|
1938 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
|
1939 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
|
1940 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
|
1941 (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
|
1942 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
|
1943 |
30968
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1944 @command('debugrebuilddirstate|debugrebuildstate', |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1945 [('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
|
1946 ('', '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
|
1947 '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
|
1948 ], |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1949 _('[-r REV]')) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1950 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
|
1951 """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
|
1952 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1953 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
|
1954 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1955 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
|
1956 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
|
1957 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
|
1958 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1959 ``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
|
1960 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
|
1961 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
|
1962 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
|
1963 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1964 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
|
1965 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
|
1966 """ |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1967 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
|
1968 with repo.wlock(): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1969 dirstate = repo.dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1970 changedfiles = None |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1971 # 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
|
1972 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
|
1973 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
|
1974 dirstatefiles = set(dirstate) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1975 manifestonly = manifestfiles - dirstatefiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1976 dsonly = dirstatefiles - manifestfiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1977 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
|
1978 changedfiles = manifestonly | dsnotadded |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1979 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30967
diff
changeset
|
1980 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
|
1981 |
30969
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1982 @command('debugrebuildfncache', [], '') |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30968
diff
changeset
|
1983 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
|
1984 """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
|
1985 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
|
1986 |
30970
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1987 @command('debugrename', |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1988 [('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
|
1989 _('[-r REV] FILE')) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1990 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
|
1991 """dump rename information""" |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1992 |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
1993 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
|
1994 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
|
1995 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
|
1996 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
|
1997 fctx = ctx[abs] |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
1998 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
|
1999 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
|
2000 if o: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
2001 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
|
2002 else: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30969
diff
changeset
|
2003 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
|
2004 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2005 @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
|
2006 [('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
|
2007 _('-c|-m|FILE'), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2008 optionalrepo=True) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2009 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
|
2010 """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
|
2011 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
|
2012 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
|
2013 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2014 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
|
2015 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2016 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
|
2017 " 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
|
2018 ts = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2019 heads = set() |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2020 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2021 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
|
2022 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
|
2023 if dbase == -1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2024 dbase = rev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2025 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
|
2026 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
|
2027 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
|
2028 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
|
2029 ts = ts + rs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2030 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
|
2031 heads.add(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2032 try: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2033 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
|
2034 except ZeroDivisionError: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2035 compression = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2036 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
|
2037 "%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
|
2038 (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
|
2039 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
|
2040 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
|
2041 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
|
2042 return 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2043 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2044 v = r.version |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2045 format = v & 0xFFFF |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2046 flags = [] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2047 gdelta = False |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
2048 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
|
2049 flags.append('inline') |
32355
67026d65a4fc
revlog: rename constants (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32305
diff
changeset
|
2050 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
|
2051 gdelta = True |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2052 flags.append('generaldelta') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2053 if not flags: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2054 flags = ['(none)'] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2055 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2056 nummerges = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2057 numfull = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2058 numprev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2059 nump1 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2060 nump2 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2061 numother = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2062 nump1prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2063 nump2prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2064 chainlengths = [] |
33069
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
2065 chainbases = [] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
2066 chainspans = [] |
30971
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2067 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2068 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
|
2069 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
|
2070 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
|
2071 chunktypecounts = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2072 chunktypesizes = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2073 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2074 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
|
2075 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
|
2076 l[0] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2077 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
|
2078 l[1] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2079 l[2] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2080 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2081 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2082 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
|
2083 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
|
2084 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
|
2085 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2086 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
|
2087 if p2 != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2088 nummerges += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2089 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
|
2090 if delta == nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2091 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
|
2092 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
|
2093 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
|
2094 numfull += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2095 addsize(size, fullsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2096 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2097 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
|
2098 baseaddr = chainbases[delta] |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
2099 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
|
2100 chainbases.append(baseaddr) |
03eefca3ed33
debugrevlog: also display the largest delta chain span
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
2101 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
|
2102 addsize(size, deltasize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2103 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
|
2104 numprev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2105 if delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2106 nump1prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2107 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2108 nump2prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2109 elif delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2110 nump1 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2111 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2112 nump2 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2113 elif delta != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2114 numother += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2115 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2116 # 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
|
2117 segment = r._getsegmentforrevs(rev, rev)[1] |
75e93d95aae6
revlog: rename _chunkraw to _getsegmentforrevs()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32249
diff
changeset
|
2118 if segment: |
33118
2f812b0d1936
py3: pass the memoryview object into bytes() to get the value
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33114
diff
changeset
|
2119 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
|
2120 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2121 chunktype = 'empty' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2122 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2123 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
|
2124 chunktypecounts[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2125 chunktypesizes[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2126 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2127 chunktypecounts[chunktype] += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2128 chunktypesizes[chunktype] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2129 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2130 # 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
|
2131 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
|
2132 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
|
2133 size[0] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2134 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2135 numdeltas = numrevs - numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2136 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
|
2137 totalrawsize = datasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2138 datasize[2] /= numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2139 fulltotal = fullsize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2140 fullsize[2] /= numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2141 deltatotal = deltasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2142 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
|
2143 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
|
2144 totalsize = fulltotal + deltatotal |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2145 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
|
2146 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
|
2147 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
|
2148 compratio = 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2149 if totalsize: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2150 compratio = totalrawsize / totalsize |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2151 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2152 basedfmtstr = '%%%dd\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2153 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
|
2154 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2155 def dfmtstr(max): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2156 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
|
2157 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
|
2158 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
|
2159 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2160 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
|
2161 if total: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2162 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
|
2163 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2164 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
|
2165 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2166 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
|
2167 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
|
2168 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2169 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2170 fmt = pcfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2171 fmt2 = dfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2172 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
|
2173 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
|
2174 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
|
2175 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
|
2176 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
|
2177 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
|
2178 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
|
2179 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
|
2180 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
|
2181 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2182 def fmtchunktype(chunktype): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2183 if chunktype == 'empty': |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2184 return ' %s : ' % chunktype |
33119
e88fdec9cb9e
py3: use pycompat.bytestr() to convert str to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33118
diff
changeset
|
2185 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
|
2186 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
|
2187 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2188 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
|
2189 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2190 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2191 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
|
2192 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
|
2193 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
|
2194 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
|
2195 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
|
2196 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
|
2197 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
|
2198 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
|
2199 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2200 ui.write('\n') |
33074
e21b750c9b9e
debugrevlog: align chain length, reach, and compression ratio
Yuya Nishihara <yuya@tcha.org>
parents:
33069
diff
changeset
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2207 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2208 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2209 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
|
2210 % tuple(datasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2211 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
|
2212 % tuple(fullsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2213 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
|
2214 % tuple(deltasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2215 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2216 if numdeltas > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2217 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2218 fmt = pcfmtstr(numdeltas) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2219 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
|
2220 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
|
2221 if numprev > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2222 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
|
2223 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2224 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
|
2225 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2226 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
|
2227 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2228 if gdelta: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2229 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
|
2230 + 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
|
2231 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
|
2232 + 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
|
2233 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
|
2234 numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30970
diff
changeset
|
2235 |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2236 @command('debugrevspec', |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2237 [('', 'optimize', None, |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2238 _('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
|
2239 ('', '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
|
2240 ('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
|
2241 ('p', 'show-stage', [], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2242 _('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
|
2243 ('', '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
|
2244 ('', '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
|
2245 ], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2246 ('REVSPEC')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2247 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
|
2248 """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
|
2249 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2250 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
|
2251 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
|
2252 |
32816
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2253 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
|
2254 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
|
2255 |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2256 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
|
2257 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
|
2258 """ |
33112
05906b8e1d23
py3: use pycompat.byteskwargs() to convert kwargs' keys to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33074
diff
changeset
|
2259 opts = pycompat.byteskwargs(opts) |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2260 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
|
2261 stages = [ |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2262 ('parsed', lambda tree: tree), |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33274
diff
changeset
|
2263 ('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
|
2264 ui.warn)), |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2265 ('concatenated', revsetlang.foldconcat), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2266 ('analyzed', revsetlang.analyze), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2267 ('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
|
2268 ] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2269 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
|
2270 stages = stages[:-1] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2271 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
|
2272 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
|
2273 '--no-optimized')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2274 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
|
2275 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2276 showalways = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2277 showchanged = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2278 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
|
2279 # 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
|
2280 showalways.add('parsed') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2281 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
|
2282 if opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2283 showalways.add('optimized') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2284 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
|
2285 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
|
2286 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
|
2287 showalways.update(stagenames) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2288 else: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2289 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
|
2290 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
|
2291 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
|
2292 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
|
2293 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2294 treebystage = {} |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2295 printedtree = None |
37350
e32dfff71529
revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37322
diff
changeset
|
2296 tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo)) |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2297 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
|
2298 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
|
2299 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
|
2300 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
|
2301 ui.write(("* %s:\n") % n) |
31044
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31008
diff
changeset
|
2302 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
|
2303 printedtree = tree |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2304 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2305 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
|
2306 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
|
2307 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
|
2308 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
38273
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38251
diff
changeset
|
2309 ui.write(("* analyzed set:\n"), stringutil.prettyrepr(arevs), "\n") |
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38251
diff
changeset
|
2310 ui.write(("* optimized set:\n"), stringutil.prettyrepr(brevs), "\n") |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2311 arevs = list(arevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2312 brevs = list(brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2313 if arevs == brevs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2314 return 0 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2315 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
|
2316 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
|
2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 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
|
2322 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
|
2323 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
|
2324 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
|
2325 if tag == 'equal': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2326 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
|
2327 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
|
2328 return 1 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2329 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2330 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
|
2331 revs = func(repo) |
32815
f78d210f599d
debugrevspec: add option to print representation of smartset object
Yuya Nishihara <yuya@tcha.org>
parents:
32765
diff
changeset
|
2332 if opts['show_set'] or (opts['show_set'] is None and ui.verbose): |
38273
f3033692ccef
stringutil: promote smartset.prettyformat() to utility function
Yuya Nishihara <yuya@tcha.org>
parents:
38251
diff
changeset
|
2333 ui.write(("* set:\n"), stringutil.prettyrepr(revs), "\n") |
32816
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2334 if not opts['show_revs']: |
bcca357bb792
debugrevspec: add option to suppress list of computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
32815
diff
changeset
|
2335 return |
30972
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30971
diff
changeset
|
2336 for c in revs: |
35942
2da4144e6716
py3: format revision number as '%d' in debugrevspec
Yuya Nishihara <yuya@tcha.org>
parents:
35928
diff
changeset
|
2337 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
|
2338 |
36556
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2339 @command('debugserve', [ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2340 ('', '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
|
2341 ('', 'logiofd', '', _('file descriptor to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2342 ('', 'logiofile', '', _('file to log server I/O to')), |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2343 ], '') |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2344 def debugserve(ui, repo, **opts): |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2345 """run a server with advanced settings |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2346 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2347 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
|
2348 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
|
2349 arguments for security reasons. |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2350 """ |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2351 opts = pycompat.byteskwargs(opts) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2352 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2353 if not opts['sshstdio']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2354 raise error.Abort(_('only --sshstdio is currently supported')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2355 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2356 logfh = None |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2357 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2358 if opts['logiofd'] and opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2359 raise error.Abort(_('cannot use both --logiofd and --logiofile')) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2360 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2361 if opts['logiofd']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2362 # Line buffered because output is line based. |
38322
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2363 try: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2364 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2365 except OSError as e: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2366 if e.errno != errno.ESPIPE: |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2367 raise |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2368 # can't seek a pipe, so `ab` mode fails on py3 |
275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
Augie Fackler <augie@google.com>
parents:
38275
diff
changeset
|
2369 logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) |
36556
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2370 elif opts['logiofile']: |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2371 logfh = open(opts['logiofile'], 'ab', 1) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2372 |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2373 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2374 s.serve_forever() |
44dc34b8d17b
debugcommands: add debugserve command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36522
diff
changeset
|
2375 |
30973
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2376 @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
|
2377 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
|
2378 """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
|
2379 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2380 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
|
2381 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
|
2382 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
|
2383 command. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2384 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2385 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
|
2386 """ |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2387 |
37146
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37123
diff
changeset
|
2388 node1 = scmutil.revsingle(repo, rev1).node() |
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37123
diff
changeset
|
2389 node2 = scmutil.revsingle(repo, rev2, 'null').node() |
30973
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2390 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2391 with repo.wlock(): |
37146
8bac14ce5778
debugsetparents: avoid using "r1/r2" variable names for nodeids
Martin von Zweigbergk <martinvonz@google.com>
parents:
37123
diff
changeset
|
2392 repo.setparents(node1, node2) |
30973
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30972
diff
changeset
|
2393 |
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
|
2394 @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
|
2395 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
|
2396 '''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
|
2397 |
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
|
2398 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
|
2399 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
|
2400 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
|
2401 |
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
|
2402 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
|
2403 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
|
2404 |
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
|
2405 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
|
2406 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
|
2407 ''' |
34645 | 2408 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
|
2409 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
|
2410 '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
|
2411 |
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
|
2412 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
|
2413 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
|
2414 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
|
2415 "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
|
2416 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
|
2417 |
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
|
2418 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
|
2419 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
|
2420 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
|
2421 |
35005
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2422 defaultport = {'https': 443, 'ssh': 22} |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2423 if url.scheme in defaultport: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2424 try: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2425 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
|
2426 except ValueError: |
88572b7e50fd
debugssl: convert port number to int (issue5757)
Yuya Nishihara <yuya@tcha.org>
parents:
34645
diff
changeset
|
2427 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
|
2428 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2429 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
|
2430 |
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
|
2431 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
|
2432 |
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
|
2433 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
|
2434 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
|
2435 |
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
|
2436 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
|
2437 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
|
2438 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
|
2439 |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2440 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
|
2441 |
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
|
2442 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
|
2443 |
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
|
2444 if not complete: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2445 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
|
2446 |
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
|
2447 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
|
2448 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
|
2449 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2450 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
|
2451 else: |
33553
9c4e2aa0a239
win32: copy-edit debugssl messages to match prevailing style
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
33507
diff
changeset
|
2452 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
|
2453 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
|
2454 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
|
2455 |
30975
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2456 @command('debugsub', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2457 [('r', 'rev', '', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2458 _('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
|
2459 _('[-r REV] [REV]')) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30974
diff
changeset
|
2460 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
|
2461 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
|
2462 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
|
2463 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
|
2464 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
|
2465 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
|
2466 |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2467 @command('debugsuccessorssets', |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2468 [('', '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
|
2469 _('[REV]')) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2470 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
|
2471 """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
|
2472 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2473 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
|
2474 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
|
2475 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
|
2476 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2477 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
|
2478 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
|
2479 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2480 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
|
2481 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
|
2482 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2483 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
|
2484 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
|
2485 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2486 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
|
2487 "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
|
2488 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
|
2489 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2490 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
|
2491 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2492 <rev1> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2493 <successors-1A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2494 <rev2> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2495 <successors-2A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2496 <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
|
2497 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2498 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
|
2499 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
|
2500 been split). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2501 """ |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2502 # 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
|
2503 cache = {} |
36161
8eb13f5d5d3f
py3: convert context to bytes instead of str
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35969
diff
changeset
|
2504 ctx2str = bytes |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2505 node2str = short |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2506 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
|
2507 ctx = repo[rev] |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2508 ui.write('%s\n'% ctx2str(ctx)) |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2509 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
|
2510 closest=opts[r'closest'], |
33274
68f3e819d41d
obsolete: closest divergent support
Boris Feld <boris.feld@octobus.net>
parents:
33273
diff
changeset
|
2511 cache=cache): |
30976
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2512 if succsset: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2513 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2514 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
|
2515 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
|
2516 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2517 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
|
2518 ui.write('\n') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
2519 |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2520 @command('debugtemplate', |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2521 [('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
|
2522 ('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
|
2523 _('[-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
|
2524 optionalrepo=True) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2525 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
|
2526 """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
|
2527 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2528 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
|
2529 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
|
2530 template. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2531 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2532 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
|
2533 """ |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2534 revs = None |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
2535 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
|
2536 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
|
2537 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
|
2538 '(.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
|
2539 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
|
2540 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2541 props = {} |
33113
b257aaa0743a
py3: use r'' to prevent the addition of b'' by transformer
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33112
diff
changeset
|
2542 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
|
2543 try: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2544 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
|
2545 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
|
2546 raise ValueError |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2547 props[k] = v |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2548 except ValueError: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2549 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
|
2550 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2551 if ui.verbose: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2552 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
|
2553 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
|
2554 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
|
2555 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
|
2556 if newtree != tree: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2557 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
|
2558 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2559 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
|
2560 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
|
2561 t = formatter.maketemplater(ui, tmpl, resources=tres) |
38361
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2562 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2563 kwds, funcs = t.symbolsuseddefault() |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2564 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2565 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
36991
317382151ac3
templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36960
diff
changeset
|
2566 ui.write(t.renderdefault(props)) |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2567 else: |
35928
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35730
diff
changeset
|
2568 displayer = logcmdutil.maketemplater(ui, repo, tmpl) |
38361
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2569 if ui.verbose: |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2570 kwds, funcs = displayer.t.symbolsuseddefault() |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2571 ui.write(("* keywords: %s\n") % ', '.join(sorted(kwds))) |
d4fae9a0ab1f
templater: add function to look up symbols used in template
Yuya Nishihara <yuya@tcha.org>
parents:
38322
diff
changeset
|
2572 ui.write(("* functions: %s\n") % ', '.join(sorted(funcs))) |
30977
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2573 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
|
2574 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
|
2575 displayer.close() |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30976
diff
changeset
|
2576 |
36800
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2577 @command('debuguigetpass', [ |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2578 ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2579 ], _('[-p TEXT]'), norepo=True) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2580 def debuguigetpass(ui, prompt=''): |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2581 """show prompt to type password""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2582 r = ui.getpass(prompt) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2583 ui.write(('respose: %s\n') % r) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2584 |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2585 @command('debuguiprompt', [ |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2586 ('p', 'prompt', '', _('prompt text'), _('TEXT')), |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2587 ], _('[-p TEXT]'), norepo=True) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2588 def debuguiprompt(ui, prompt=''): |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2589 """show plain prompt""" |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2590 r = ui.prompt(prompt) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2591 ui.write(('response: %s\n') % r) |
15c050b5d599
ui: add debug commands to test interactive prompt
Yuya Nishihara <yuya@tcha.org>
parents:
36789
diff
changeset
|
2592 |
32305
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2593 @command('debugupdatecaches', []) |
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2594 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
|
2595 """warm all known caches in the repository""" |
33438 | 2596 with repo.wlock(), repo.lock(): |
36958
b24cde12061b
debugupdatecache: also warm rev branch cache
Boris Feld <boris.feld@octobus.net>
parents:
36957
diff
changeset
|
2597 repo.updatecaches(full=True) |
32305
ccef71de7d41
caches: introduce a 'debugupdatecaches' command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32296
diff
changeset
|
2598 |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2599 @command('debugupgraderepo', [ |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2600 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2601 ('', 'run', False, _('performs an upgrade')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2602 ]) |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2603 def debugupgraderepo(ui, repo, run=False, optimize=None): |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2604 """upgrade a repository to use different features |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2605 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2606 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
|
2607 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
|
2608 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2609 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
|
2610 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
|
2611 by the command output when run without ``--run``. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2612 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2613 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
|
2614 allowed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2615 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2616 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
|
2617 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
|
2618 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
|
2619 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
|
2620 unable to access the repository should be low. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2621 """ |
31864
70d163b86316
upgrade: extract code in its own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31694
diff
changeset
|
2622 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
|
2623 |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2624 @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
|
2625 inferrepo=True) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2626 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
|
2627 """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
|
2628 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
|
2629 m = scmutil.match(repo[None], pats, opts) |
38274
7c3a59e2971b
debugwalk: show matcher output only if -v/--verbose
Yuya Nishihara <yuya@tcha.org>
parents:
38273
diff
changeset
|
2630 if ui.verbose: |
38275
dbf31732ef64
debugwalk: pretty-print nested matcher
Yuya Nishihara <yuya@tcha.org>
parents:
38274
diff
changeset
|
2631 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') |
32402
a275186b989a
debugcommands: use repo[None].walk instead of repo.walk
Augie Fackler <augie@google.com>
parents:
32376
diff
changeset
|
2632 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
|
2633 if not items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2634 return |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30977
diff
changeset
|
2635 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
|
2636 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
|
2637 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
|
2638 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
|
2639 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
|
2640 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
|
2641 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
|
2642 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
|
2643 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
|
2644 |
36960
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2645 @command('debugwhyunstable', [], _('REV')) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2646 def debugwhyunstable(ui, repo, rev): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2647 """explain instabilities of a changeset""" |
37396
9966f44ecab4
debugwhyunstable: add support for revsets
Martin von Zweigbergk <martinvonz@google.com>
parents:
37350
diff
changeset
|
2648 for entry in obsutil.whyunstable(repo, scmutil.revsingle(repo, rev)): |
36960
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2649 dnodes = '' |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2650 if entry.get('divergentnodes'): |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2651 dnodes = ' '.join('%s (%s)' % (ctx.hex(), ctx.phasestr()) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2652 for ctx in entry['divergentnodes']) + ' ' |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2653 ui.write('%s: %s%s %s\n' % (entry['instability'], dnodes, |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2654 entry['reason'], entry['node'])) |
efc4fb344c05
debug: add debugwhyunstable that explains instabilities
Anton Shestakov <av6@dwimlabs.net>
parents:
36958
diff
changeset
|
2655 |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2656 @command('debugwireargs', |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2657 [('', 'three', '', 'three'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2658 ('', 'four', '', 'four'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2659 ('', 'five', '', 'five'), |
32414
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32410
diff
changeset
|
2660 ] + cmdutil.remoteopts, |
30979
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2661 _('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
|
2662 norepo=True) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2663 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
|
2664 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
|
2665 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
|
2666 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
|
2667 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
|
2668 args = {} |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2669 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
|
2670 if v: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2671 args[k] = v |
35408
cd3392cb5818
py3: handle keyword arguments correctly in debugcommands.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35407
diff
changeset
|
2672 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
|
2673 # 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
|
2674 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
|
2675 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
|
2676 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
|
2677 if res1 != res2: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30978
diff
changeset
|
2678 ui.warn("%s\n" % res2) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2679 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2680 def _parsewirelangblocks(fh): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2681 activeaction = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2682 blocklines = [] |
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 for line in fh: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2685 line = line.rstrip() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2686 if not line: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2687 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2688 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2689 if line.startswith(b'#'): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2690 continue |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2691 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2692 if not line.startswith(' '): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2693 # New block. Flush previous one. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2694 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2695 yield activeaction, blocklines |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2696 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2697 activeaction = line |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2698 blocklines = [] |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2699 continue |
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 we start with an indent. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2702 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2703 if not activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2704 raise error.Abort(_('indented line outside of block')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2705 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2706 blocklines.append(line) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2707 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2708 # Flush last block. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2709 if activeaction: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2710 yield activeaction, blocklines |
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 @command('debugwireproto', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2713 [ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2714 ('', 'localssh', False, _('start an SSH server for this repo')), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2715 ('', 'peer', '', _('construct a specific version of the peer')), |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2716 ('', 'noreadstderr', False, _('do not read from stderr of the remote')), |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
2717 ('', 'nologhandshake', False, |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
2718 _('do not log I/O related to the peer handshake')), |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2719 ] + cmdutil.remoteopts, |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2720 _('[PATH]'), |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2721 optionalrepo=True) |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2722 def debugwireproto(ui, repo, path=None, **opts): |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2723 """send wire protocol commands to a server |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2724 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2725 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
|
2726 peers and to debug the raw data being exchanged. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2727 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2728 ``--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
|
2729 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
|
2730 and establish an appropriate peer instance. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2731 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2732 ``--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
|
2733 peer instance using the specified class type. Valid values are ``raw``, |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2734 ``http2``, ``ssh1``, and ``ssh2``. ``raw`` instances only allow sending |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2735 raw data payloads and don't support higher-level command actions. |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2736 |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2737 ``--noreadstderr`` can be used to disable automatic reading from stderr |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2738 of the peer (for SSH connections only). Disabling automatic reading of |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2739 stderr is useful for making output more deterministic. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2740 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2741 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
|
2742 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
|
2743 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
|
2744 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
|
2745 effectively a high-level command with additional metadata. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2746 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2747 Lines beginning with ``#`` are ignored. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2748 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2749 The following sections denote available actions. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2750 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2751 raw |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2752 --- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2753 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2754 Send raw data to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2755 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2756 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
|
2757 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
|
2758 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
|
2759 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2760 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
|
2761 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
|
2762 backslash escaping, etc. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2763 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2764 raw+ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2765 ---- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2766 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2767 Behaves like ``raw`` except flushes output afterwards. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2768 |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2769 command <X> |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2770 ----------- |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2771 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2772 Send a request to run a named command, whose name follows the ``command`` |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2773 string. |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2774 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2775 Arguments to the command are defined as lines in this block. The format of |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2776 each line is ``<key> <value>``. e.g.:: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2777 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2778 command listkeys |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2779 namespace bookmarks |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2780 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2781 If the value begins with ``eval:``, it will be interpreted as a Python |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2782 literal expression. Otherwise values are interpreted as Python b'' literals. |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2783 This allows sending complex types and encoding special byte sequences via |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2784 backslash escaping. |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
2785 |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2786 The following arguments have special meaning: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2787 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2788 ``PUSHFILE`` |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2789 When defined, the *push* mechanism of the peer will be used instead |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2790 of the static request-response mechanism and the content of the |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2791 file specified in the value of this argument will be sent as the |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2792 command payload. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2793 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2794 This can be used to submit a local bundle file to the remote. |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2795 |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2796 batchbegin |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2797 ---------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2798 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2799 Instruct the peer to begin a batched send. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2800 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2801 All ``command`` blocks are queued for execution until the next |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2802 ``batchsubmit`` block. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2803 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2804 batchsubmit |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2805 ----------- |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2806 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2807 Submit previously queued ``command`` blocks as a batch request. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2808 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2809 This action MUST be paired with a ``batchbegin`` action. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
2810 |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2811 httprequest <method> <path> |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2812 --------------------------- |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2813 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2814 (HTTP peer only) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2815 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2816 Send an HTTP request to the peer. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2817 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2818 The HTTP request line follows the ``httprequest`` action. e.g. ``GET /foo``. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2819 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2820 Arguments of the form ``<key>: <value>`` are interpreted as HTTP request |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2821 headers to add to the request. e.g. ``Accept: foo``. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2822 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2823 The following arguments are special: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2824 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2825 ``BODYFILE`` |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2826 The content of the file defined as the value to this argument will be |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2827 transferred verbatim as the HTTP request body. |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2828 |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2829 ``frame <type> <flags> <payload>`` |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2830 Send a unified protocol frame as part of the request body. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2831 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2832 All frames will be collected and sent as the body to the HTTP |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2833 request. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2834 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2835 close |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2836 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2837 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2838 Close the connection to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2839 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2840 flush |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2841 ----- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2842 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2843 Flush data written to the server. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2844 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2845 readavailable |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2846 ------------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2847 |
36851
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
2848 Close the write end of the connection and read all available data from |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
2849 the server. |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2850 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2851 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
|
2852 pipes and read available data. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2853 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2854 readline |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2855 -------- |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2856 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2857 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
|
2858 pipes, reads only the main pipe. |
37010
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2859 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2860 ereadline |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2861 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2862 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2863 Like ``readline``, but read from the stderr pipe, if available. |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2864 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2865 read <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2866 -------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2867 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2868 ``read()`` N bytes from the server's main output pipe. |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2869 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2870 eread <X> |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2871 --------- |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2872 |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
2873 ``read()`` N bytes from the server's stderr pipe, if available. |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2874 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2875 Specifying Unified Frame-Based Protocol Frames |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2876 ---------------------------------------------- |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2877 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2878 It is possible to emit a *Unified Frame-Based Protocol* by using special |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2879 syntax. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2880 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2881 A frame is composed as a type, flags, and payload. These can be parsed |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2882 from a string of the form: |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2883 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2884 <request-id> <stream-id> <stream-flags> <type> <flags> <payload> |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2885 |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2886 ``request-id`` and ``stream-id`` are integers defining the request and |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2887 stream identifiers. |
37060
2ec1fb9de638
wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37054
diff
changeset
|
2888 |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2889 ``type`` can be an integer value for the frame type or the string name |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2890 of the type. The strings are defined in ``wireprotoframing.py``. e.g. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2891 ``command-name``. |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
2892 |
37288
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2893 ``stream-flags`` and ``flags`` are a ``|`` delimited list of flag |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2894 components. Each component (and there can be just one) can be an integer |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2895 or a flag name for stream flags or frame flags, respectively. Values are |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2896 resolved to integers and then bitwise OR'd together. |
9bfcbe4f4745
wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37285
diff
changeset
|
2897 |
37290
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
2898 ``payload`` represents the raw frame payload. If it begins with |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
2899 ``cbor:``, the following string is evaluated as Python code and the |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
2900 resulting object is fed into a CBOR encoder. Otherwise it is interpreted |
cc5a040fe150
wireproto: syntax for encoding CBOR into frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37288
diff
changeset
|
2901 as a Python byte string literal. |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2902 """ |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2903 opts = pycompat.byteskwargs(opts) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2904 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2905 if opts['localssh'] and not repo: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2906 raise error.Abort(_('--localssh requires a repository')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2907 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2908 if opts['peer'] and opts['peer'] not in ('raw', 'http2', 'ssh1', 'ssh2'): |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2909 raise error.Abort(_('invalid value for --peer'), |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2910 hint=_('valid values are "raw", "ssh1", and "ssh2"')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2911 |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2912 if path and opts['localssh']: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2913 raise error.Abort(_('cannot specify --localssh with an explicit ' |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2914 'path')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2915 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2916 if ui.interactive(): |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2917 ui.write(_('(waiting for commands on stdin)\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2918 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2919 blocks = list(_parsewirelangblocks(ui.fin)) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2920 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2921 proc = None |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2922 stdin = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2923 stdout = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2924 stderr = None |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
2925 opener = None |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2926 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2927 if opts['localssh']: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2928 # 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
|
2929 # 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
|
2930 # shared state from interfering with server operation. |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
2931 args = procutil.hgcmd() + [ |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2932 '-R', repo.root, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2933 'debugserve', '--sshstdio', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2934 ] |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2935 proc = subprocess.Popen(args, stdin=subprocess.PIPE, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2936 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2937 bufsize=0) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2938 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2939 stdin = proc.stdin |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2940 stdout = proc.stdout |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2941 stderr = proc.stderr |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2942 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2943 # 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
|
2944 if ui.verbose or opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2945 stdin = util.makeloggingfileobject(ui, proc.stdin, b'i', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2946 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2947 stdout = util.makeloggingfileobject(ui, proc.stdout, b'o', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2948 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2949 stderr = util.makeloggingfileobject(ui, proc.stderr, b'e', |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2950 logdata=True) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2951 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2952 # --localssh also implies the peer connection settings. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2953 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2954 url = 'ssh://localserver' |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2955 autoreadstderr = not opts['noreadstderr'] |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2956 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2957 if opts['peer'] == 'ssh1': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2958 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
|
2959 peer = sshpeer.sshv1peer(ui, url, proc, stdin, stdout, stderr, |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2960 None, autoreadstderr=autoreadstderr) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2961 elif opts['peer'] == 'ssh2': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2962 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
|
2963 peer = sshpeer.sshv2peer(ui, url, proc, stdin, stdout, stderr, |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2964 None, autoreadstderr=autoreadstderr) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2965 elif opts['peer'] == 'raw': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2966 ui.write(_('using raw connection to peer\n')) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2967 peer = None |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2968 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2969 ui.write(_('creating ssh peer from handshake results\n')) |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2970 peer = sshpeer.makepeer(ui, url, proc, stdin, stdout, stderr, |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
2971 autoreadstderr=autoreadstderr) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
2972 |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2973 elif path: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2974 # We bypass hg.peer() so we can proxy the sockets. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2975 # TODO consider not doing this because we skip |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2976 # ``hg.wirepeersetupfuncs`` and potentially other useful functionality. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2977 u = util.url(path) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2978 if u.scheme != 'http': |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2979 raise error.Abort(_('only http:// paths are currently supported')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2980 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2981 url, authinfo = u.authinfo() |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2982 openerargs = { |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2983 r'useragent': b'Mercurial debugwireproto', |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2984 } |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2985 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2986 # Turn pipes/sockets into observers so we can log I/O. |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2987 if ui.verbose: |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2988 openerargs.update({ |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2989 r'loggingfh': ui, |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2990 r'loggingname': b's', |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2991 r'loggingopts': { |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2992 r'logdata': True, |
37047
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37016
diff
changeset
|
2993 r'logdataapis': False, |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2994 }, |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
2995 }) |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
2996 |
37047
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37016
diff
changeset
|
2997 if ui.debugflag: |
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37016
diff
changeset
|
2998 openerargs[r'loggingopts'][r'logdataapis'] = True |
d3a9036d9ae9
util: don't log low-level I/O calls for HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37016
diff
changeset
|
2999 |
37048
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3000 # Don't send default headers when in raw mode. This allows us to |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3001 # bypass most of the behavior of our URL handling code so we can |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3002 # have near complete control over what's sent on the wire. |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3003 if opts['peer'] == 'raw': |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3004 openerargs[r'sendaccept'] = False |
a708e1e4d7a8
url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37047
diff
changeset
|
3005 |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3006 opener = urlmod.opener(ui, authinfo, **openerargs) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3007 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3008 if opts['peer'] == 'http2': |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3009 ui.write(_('creating http peer for wire protocol version 2\n')) |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3010 # We go through makepeer() because we need an API descriptor for |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3011 # the peer instance to be useful. |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3012 with ui.configoverride({ |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3013 ('experimental', 'httppeer.advertise-v2'): True}): |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3014 if opts['nologhandshake']: |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3015 ui.pushbuffer() |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3016 |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3017 peer = httppeer.makepeer(ui, path, opener=opener) |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3018 |
37718
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3019 if opts['nologhandshake']: |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3020 ui.popbuffer() |
ad1c07008e0b
debugcommands: ability to suppress logging of handshake
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37652
diff
changeset
|
3021 |
37645
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3022 if not isinstance(peer, httppeer.httpv2peer): |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3023 raise error.Abort(_('could not instantiate HTTP peer for ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3024 'wire protocol version 2'), |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3025 hint=_('the server may not have the feature ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3026 'enabled or is not allowing this ' |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3027 'client version')) |
72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37644
diff
changeset
|
3028 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3029 elif opts['peer'] == 'raw': |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3030 ui.write(_('using raw connection to peer\n')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3031 peer = None |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3032 elif opts['peer']: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3033 raise error.Abort(_('--peer %s not supported with HTTP peers') % |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3034 opts['peer']) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3035 else: |
37553
6b08cf6b900f
httppeer: allow opener to be passed to makepeer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37552
diff
changeset
|
3036 peer = httppeer.makepeer(ui, path, opener=opener) |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3037 |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3038 # We /could/ populate stdin/stdout with sock.makefile()... |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3039 else: |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3040 raise error.Abort(_('unsupported connection configuration')) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3041 |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3042 batchedcommands = None |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3043 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3044 # 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
|
3045 for action, lines in blocks: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3046 if action in ('raw', 'raw+'): |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3047 if not stdin: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3048 raise error.Abort(_('cannot call raw/raw+ on this peer')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3049 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3050 # Concatenate the data together. |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3051 data = ''.join(l.lstrip() for l in lines) |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
3052 data = stringutil.unescapestr(data) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3053 stdin.write(data) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3054 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3055 if action == 'raw+': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3056 stdin.flush() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3057 elif action == 'flush': |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3058 if not stdin: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3059 raise error.Abort(_('cannot call flush on this peer')) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3060 stdin.flush() |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3061 elif action.startswith('command'): |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3062 if not peer: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3063 raise error.Abort(_('cannot send commands unless peer instance ' |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3064 'is available')) |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3065 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3066 command = action.split(' ', 1)[1] |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3067 |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3068 args = {} |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3069 for line in lines: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3070 # We need to allow empty values. |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3071 fields = line.lstrip().split(' ', 1) |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3072 if len(fields) == 1: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3073 key = fields[0] |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3074 value = '' |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3075 else: |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3076 key, value = fields |
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3077 |
37483
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3078 if value.startswith('eval:'): |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3079 value = stringutil.evalpythonliteral(value[5:]) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3080 else: |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3081 value = stringutil.unescapestr(value) |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3082 |
61e405fb6372
wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37396
diff
changeset
|
3083 args[key] = value |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3084 |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3085 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3086 batchedcommands.append((command, args)) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3087 continue |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3088 |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3089 ui.status(_('sending %s command\n') % command) |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3090 |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3091 if 'PUSHFILE' in args: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3092 with open(args['PUSHFILE'], r'rb') as fh: |
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3093 del args['PUSHFILE'] |
36616
dfcf589a4031
debugcommands: add some strkwargs love to some **args calls
Augie Fackler <augie@google.com>
parents:
36615
diff
changeset
|
3094 res, output = peer._callpush(command, fh, |
dfcf589a4031
debugcommands: add some strkwargs love to some **args calls
Augie Fackler <augie@google.com>
parents:
36615
diff
changeset
|
3095 **pycompat.strkwargs(args)) |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3096 ui.status(_('result: %s\n') % stringutil.escapestr(res)) |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3097 ui.status(_('remote output: %s\n') % |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3098 stringutil.escapestr(output)) |
36563
5faeabb07cf5
debugcommands: support for triggering push protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36560
diff
changeset
|
3099 else: |
37652
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3100 with peer.commandexecutor() as e: |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3101 res = e.callcommand(command, args).result() |
fe8c6f9f2914
debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
3102 |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
3103 if isinstance(res, wireprotov2peer.commandresponse): |
37722
89a16704114c
wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37720
diff
changeset
|
3104 val = list(res.cborobjects()) |
37986
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3105 ui.status(_('response: %s\n') % |
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3106 stringutil.pprint(val, bprefix=True)) |
37720
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
3107 |
d715a85003c8
wireprotov2: establish a type for representing command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37718
diff
changeset
|
3108 else: |
37986
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3109 ui.status(_('response: %s\n') % |
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3110 stringutil.pprint(res, bprefix=True)) |
36559
bde0bd50f368
debugcommands: allow sending of simple commands with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36557
diff
changeset
|
3111 |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3112 elif action == 'batchbegin': |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3113 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3114 raise error.Abort(_('nested batchbegin not allowed')) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3115 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3116 batchedcommands = [] |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3117 elif action == 'batchsubmit': |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3118 # There is a batching API we could go through. But it would be |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3119 # difficult to normalize requests into function calls. It is easier |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3120 # to bypass this layer and normalize to commands + args. |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3121 ui.status(_('sending batch with %d sub-commands\n') % |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3122 len(batchedcommands)) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3123 for i, chunk in enumerate(peer._submitbatch(batchedcommands)): |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37060
diff
changeset
|
3124 ui.status(_('response #%d: %s\n') % |
37322
a67fd1fe5109
stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents:
37300
diff
changeset
|
3125 (i, stringutil.escapestr(chunk))) |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3126 |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3127 batchedcommands = None |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3128 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3129 elif action.startswith('httprequest '): |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3130 if not opener: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3131 raise error.Abort(_('cannot use httprequest without an HTTP ' |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3132 'peer')) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3133 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3134 request = action.split(' ', 2) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3135 if len(request) != 3: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3136 raise error.Abort(_('invalid httprequest: expected format is ' |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3137 '"httprequest <method> <path>')) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3138 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3139 method, httppath = request[1:] |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3140 headers = {} |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3141 body = None |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3142 frames = [] |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3143 for line in lines: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3144 line = line.lstrip() |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3145 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3146 if m: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3147 headers[m.group(1)] = m.group(2) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3148 continue |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3149 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3150 if line.startswith(b'BODYFILE '): |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3151 with open(line.split(b' ', 1), 'rb') as fh: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3152 body = fh.read() |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3153 elif line.startswith(b'frame '): |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3154 frame = wireprotoframing.makeframefromhumanstring( |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3155 line[len(b'frame '):]) |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3156 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3157 frames.append(frame) |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3158 else: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3159 raise error.Abort(_('unknown argument to httprequest: %s') % |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3160 line) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3161 |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3162 url = path + httppath |
37054
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3163 |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3164 if frames: |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3165 body = b''.join(bytes(f) for f in frames) |
40206e227412
wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37050
diff
changeset
|
3166 |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3167 req = urlmod.urlreq.request(pycompat.strurl(url), body, headers) |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3168 |
37050
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37048
diff
changeset
|
3169 # urllib.Request insists on using has_data() as a proxy for |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37048
diff
changeset
|
3170 # determining the request method. Override that to use our |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37048
diff
changeset
|
3171 # explicitly requested method. |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37048
diff
changeset
|
3172 req.get_method = lambda: method |
fddcb51b5084
wireproto: define permissions-based routing of HTTPv2 wire protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37048
diff
changeset
|
3173 |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3174 try: |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3175 res = opener.open(req) |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3176 body = res.read() |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3177 except util.urlerr.urlerror as e: |
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3178 e.read() |
37557
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3179 continue |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3180 |
734515aca84d
wireproto: define and implement HTTP handshake to upgrade protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37553
diff
changeset
|
3181 if res.headers.get('Content-Type') == 'application/mercurial-cbor': |
37986
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3182 ui.write(_('cbor> %s\n') % |
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37823
diff
changeset
|
3183 stringutil.pprint(cbor.loads(body), bprefix=True)) |
37016
b6a7070e7663
debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37015
diff
changeset
|
3184 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3185 elif action == 'close': |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3186 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3187 elif action == 'readavailable': |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3188 if not stdout or not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3189 raise error.Abort(_('readavailable not available on this peer')) |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3190 |
36851
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
3191 stdin.close() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
3192 stdout.read() |
31581528f242
debugwireproto: close the write end before consuming all available data
Yuya Nishihara <yuya@tcha.org>
parents:
36843
diff
changeset
|
3193 stderr.read() |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3194 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3195 elif action == 'readline': |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3196 if not stdout: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3197 raise error.Abort(_('readline not available on this peer')) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3198 stdout.readline() |
37010
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3199 elif action == 'ereadline': |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3200 if not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3201 raise error.Abort(_('ereadline not available on this peer')) |
37010
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3202 stderr.readline() |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3203 elif action.startswith('read '): |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3204 count = int(action.split(' ', 1)[1]) |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3205 if not stdout: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3206 raise error.Abort(_('read not available on this peer')) |
37010
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3207 stdout.read(count) |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3208 elif action.startswith('eread '): |
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3209 count = int(action.split(' ', 1)[1]) |
37015
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3210 if not stderr: |
fc8939825632
debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37010
diff
changeset
|
3211 raise error.Abort(_('eread not available on this peer')) |
37010
143219fc2620
debugcommands: introduce actions to perform deterministic reads
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36991
diff
changeset
|
3212 stderr.read(count) |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3213 else: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3214 raise error.Abort(_('unknown action: %s') % action) |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3215 |
36560
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3216 if batchedcommands is not None: |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3217 raise error.Abort(_('unclosed "batchbegin" request')) |
097ad1079192
debugcommands: support for sending "batch" requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36559
diff
changeset
|
3218 |
36557
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3219 if peer: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3220 peer.close() |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3221 |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3222 if proc: |
72e487851a53
debugcommands: add debugwireproto command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36556
diff
changeset
|
3223 proc.kill() |