Mercurial > hg
annotate mercurial/debugcommands.py @ 31803:2be73f9720a8
revlog: indent block to make review easier
author | Jun Wu <quark@fb.com> |
---|---|
date | Sun, 02 Apr 2017 18:29:24 -0700 |
parents | 57a22f699179 |
children | 70d163b86316 |
rev | line source |
---|---|
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # debugcommands.py - command processing for debug* commands |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2005-2016 Matt Mackall <mpm@selenic.com> |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
10 import difflib |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
11 import errno |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
12 import operator |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
13 import os |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
14 import random |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
15 import socket |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
16 import string |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
17 import sys |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
18 import tempfile |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
19 import time |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 from .i18n import _ |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
22 from .node import ( |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
23 bin, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
24 hex, |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
25 nullhex, |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
26 nullid, |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
27 nullrev, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
28 short, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
29 ) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 from . import ( |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
31 bundle2, |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
32 changegroup, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 cmdutil, |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
34 color, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 commands, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
36 context, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
37 dagparser, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
38 dagutil, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
39 encoding, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 error, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
41 exchange, |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
42 extensions, |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
43 fileset, |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
44 formatter, |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
45 hg, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
46 localrepo, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
47 lock as lockmod, |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
48 merge as mergemod, |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
49 obsolete, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
50 policy, |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
51 pvec, |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30518
diff
changeset
|
52 pycompat, |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
53 repair, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 revlog, |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
55 revset, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
56 revsetlang, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 scmutil, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
58 setdiscovery, |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
59 simplemerge, |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
60 smartset, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
61 sslutil, |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
62 streamclone, |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
63 templater, |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
64 treediscovery, |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
65 util, |
31239
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
66 vfs as vfsmod, |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 ) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
69 release = lockmod.release |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
70 |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 # We reuse the command table from commands because it is easier than |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 # teaching dispatch about multiple tables. |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 command = cmdutil.command(commands.table) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 def debugancestor(ui, repo, *args): |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 """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
|
78 if len(args) == 3: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 index, rev1, rev2 = args |
31239
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
80 r = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), index) |
30401
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 lookup = r.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 elif len(args) == 2: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 if not repo: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 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
|
85 '(.hg not found)')) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 rev1, rev2 = args |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 r = repo.changelog |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 lookup = repo.lookup |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 else: |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 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
|
91 a = r.ancestor(lookup(rev1), lookup(rev2)) |
869d660b8669
debugcommands: introduce standalone module for debug commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 ui.write('%d:%s\n' % (r.rev(a), hex(a))) |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
93 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
94 @command('debugapplystreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
95 def debugapplystreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
96 """apply a stream clone bundle file""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
97 f = hg.openpath(ui, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
98 gen = exchange.readbundle(ui, f, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
99 gen.apply(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
100 |
30402
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
101 @command('debugbuilddag', |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
102 [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
103 ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
104 ('n', 'new-file', None, _('add new file at each rev'))], |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
105 _('[OPTION]... [TEXT]')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
106 def debugbuilddag(ui, repo, text=None, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
107 mergeable_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
108 overwritten_file=False, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
109 new_file=False): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
110 """builds a repo with a given DAG from scratch in the current empty repo |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
111 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
112 The description of the DAG is read from stdin if not given on the |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
113 command line. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
114 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
115 Elements: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
116 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
117 - "+n" is a linear run of n nodes based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
118 - "." is a single node based on the current default parent |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
119 - "$" resets the default parent to null (implied at the start); |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
120 otherwise the default parent is always the last node created |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
121 - "<p" sets the default parent to the backref p |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
122 - "*p" is a fork at parent p, which is a backref |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
123 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
124 - "/p2" is a merge of the preceding node and p2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
125 - ":tag" defines a local tag for the preceding node |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
126 - "@branch" sets the named branch for subsequent nodes |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
127 - "#...\\n" is a comment up to the end of the line |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
128 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
129 Whitespace between the above elements is ignored. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
130 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
131 A backref is either |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
132 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
133 - a number n, which references the node curr-n, where curr is the current |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
134 node, or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
135 - the name of a local tag you placed earlier using ":tag", or |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
136 - empty to denote the default parent. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
137 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
138 All string valued-elements are either strictly alphanumeric, or must |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
139 be enclosed in double quotes ("..."), with "\\" as escape character. |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
140 """ |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
141 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
142 if text is None: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
143 ui.status(_("reading DAG from stdin\n")) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
144 text = ui.fin.read() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
145 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
146 cl = repo.changelog |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
147 if len(cl) > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
148 raise error.Abort(_('repository is not empty')) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
149 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
150 # determine number of revs in DAG |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
151 total = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
152 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
153 if type == 'n': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
154 total += 1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
155 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
156 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
157 linesperrev = 2 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
158 # make a file with k lines per rev |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
159 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
160 initialmergedlines.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
161 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
162 tags = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
163 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
164 wlock = lock = tr = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
165 try: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
166 wlock = repo.wlock() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
167 lock = repo.lock() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
168 tr = repo.transaction("builddag") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
169 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
170 at = -1 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
171 atbranch = 'default' |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
172 nodeids = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
173 id = 0 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
174 ui.progress(_('building'), id, unit=_('revisions'), total=total) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
175 for type, data in dagparser.parsedag(text): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
176 if type == 'n': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
177 ui.note(('node %s\n' % str(data))) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
178 id, ps = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
179 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
180 files = [] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
181 fctxs = {} |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
182 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
183 p2 = None |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
184 if mergeable_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
185 fn = "mf" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
186 p1 = repo[ps[0]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
187 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
188 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
189 pa = p1.ancestor(p2) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
190 base, local, other = [x[fn].data() for x in (pa, p1, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
191 p2)] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
192 m3 = simplemerge.Merge3Text(base, local, other) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
193 ml = [l.strip() for l in m3.merge_lines()] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
194 ml.append("") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
195 elif at > 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
196 ml = p1[fn].data().split("\n") |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
197 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
198 ml = initialmergedlines |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
199 ml[id * linesperrev] += " r%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
200 mergedtext = "\n".join(ml) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
201 files.append(fn) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
202 fctxs[fn] = context.memfilectx(repo, fn, mergedtext) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
203 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
204 if overwritten_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
205 fn = "of" |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
206 files.append(fn) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
207 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
208 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
209 if new_file: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
210 fn = "nf%i" % id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
211 files.append(fn) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
212 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
213 if len(ps) > 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
214 if not p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
215 p2 = repo[ps[1]] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
216 for fn in p2: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
217 if fn.startswith("nf"): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
218 files.append(fn) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
219 fctxs[fn] = p2[fn] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
220 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
221 def fctxfn(repo, cx, path): |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
222 return fctxs.get(path) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
223 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
224 if len(ps) == 0 or ps[0] < 0: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
225 pars = [None, None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
226 elif len(ps) == 1: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
227 pars = [nodeids[ps[0]], None] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
228 else: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
229 pars = [nodeids[p] for p in ps] |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
230 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn, |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
231 date=(id, 0), |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
232 user="debugbuilddag", |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
233 extra={'branch': atbranch}) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
234 nodeid = repo.commitctx(cx) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
235 nodeids.append(nodeid) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
236 at = id |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
237 elif type == 'l': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
238 id, name = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
239 ui.note(('tag %s\n' % name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
240 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
241 elif type == 'a': |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
242 ui.note(('branch %s\n' % data)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
243 atbranch = data |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
244 ui.progress(_('building'), id, unit=_('revisions'), total=total) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
245 tr.close() |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
246 |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
247 if tags: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
248 repo.vfs.write("localtags", "".join(tags)) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
249 finally: |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
250 ui.progress(_('building'), None) |
945f8229b30d
debugcommands: move debugbuilddag
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30401
diff
changeset
|
251 release(tr, lock, wlock) |
30501
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
252 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
253 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
254 indent_string = ' ' * indent |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
255 if all: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
256 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
257 % indent_string) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
258 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
259 def showchunks(named): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
260 ui.write("\n%s%s\n" % (indent_string, named)) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
261 chain = None |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
262 for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
263 node = chunkdata['node'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
264 p1 = chunkdata['p1'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
265 p2 = chunkdata['p2'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
266 cs = chunkdata['cs'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
267 deltabase = chunkdata['deltabase'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
268 delta = chunkdata['delta'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
269 ui.write("%s%s %s %s %s %s %s\n" % |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
270 (indent_string, hex(node), hex(p1), hex(p2), |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
271 hex(cs), hex(deltabase), len(delta))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
272 chain = node |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
273 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
274 chunkdata = gen.changelogheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
275 showchunks("changelog") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
276 chunkdata = gen.manifestheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
277 showchunks("manifest") |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
278 for chunkdata in iter(gen.filelogheader, {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
279 fname = chunkdata['filename'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
280 showchunks(fname) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
281 else: |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
282 if isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
283 raise error.Abort(_('use debugbundle2 for this file')) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
284 chunkdata = gen.changelogheader() |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
285 chain = None |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
286 for chunkdata in iter(lambda: gen.deltachunk(chain), {}): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
287 node = chunkdata['node'] |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
288 ui.write("%s%s\n" % (indent_string, hex(node))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
289 chain = node |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
290 |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
291 def _debugbundle2(ui, gen, all=None, **opts): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
292 """lists the contents of a bundle2""" |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
293 if not isinstance(gen, bundle2.unbundle20): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
294 raise error.Abort(_('not a bundle2 file')) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
295 ui.write(('Stream params: %s\n' % repr(gen.params))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
296 for part in gen.iterparts(): |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
297 ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
298 if part.type == 'changegroup': |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
299 version = part.params.get('version', '01') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
300 cg = changegroup.getunbundler(version, part, 'UN') |
a87e469201f9
debugcommands: move 'debugbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30402
diff
changeset
|
301 _debugchangegroup(ui, cg, all=all, indent=4, **opts) |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
302 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
303 @command('debugbundle', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
304 [('a', 'all', None, _('show all details')), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
305 ('', 'spec', None, _('print the bundlespec of the bundle'))], |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
306 _('FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
307 norepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
308 def debugbundle(ui, bundlepath, all=None, spec=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
309 """lists the contents of a bundle""" |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
310 with hg.openpath(ui, bundlepath) as f: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
311 if spec: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
312 spec = exchange.getbundlespec(ui, f) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
313 ui.write('%s\n' % spec) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
314 return |
30502
6da030496667
debugcommands: move debug{create,apply}streambundleclone to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30501
diff
changeset
|
315 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
316 gen = exchange.readbundle(ui, f, bundlepath) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
317 if isinstance(gen, bundle2.unbundle20): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
318 return _debugbundle2(ui, gen, all=all, **opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
319 _debugchangegroup(ui, gen, all=all, **opts) |
30503
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
320 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
321 @command('debugcheckstate', [], '') |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
322 def debugcheckstate(ui, repo): |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
323 """validate the correctness of the current dirstate""" |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
324 parent1, parent2 = repo.dirstate.parents() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
325 m1 = repo[parent1].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
326 m2 = repo[parent2].manifest() |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
327 errors = 0 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
328 for f in repo.dirstate: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
329 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
330 if state in "nr" and f not in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
331 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
332 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
333 if state in "a" and f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
334 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
335 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
336 if state in "m" and f not in m1 and f not in m2: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
337 ui.warn(_("%s in state %s, but not in either manifest\n") % |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
338 (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
339 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
340 for f in m1: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
341 state = repo.dirstate[f] |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
342 if state not in "nrm": |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
343 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
344 errors += 1 |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
345 if errors: |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
346 error = _(".hg/dirstate inconsistent with current parent's manifest") |
6bfb333a6f2f
debugcommands: move 'debugcheckstate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30502
diff
changeset
|
347 raise error.Abort(error) |
30504
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
348 |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
349 @command('debugcolor', |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
350 [('', 'style', None, _('show all configured styles'))], |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
351 'hg debugcolor') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
352 def debugcolor(ui, repo, **opts): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
353 """show available color, effects or style""" |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
354 ui.write(('color mode: %s\n') % ui._colormode) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
355 if opts.get('style'): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
356 return _debugdisplaystyle(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
357 else: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
358 return _debugdisplaycolor(ui) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
359 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
360 def _debugdisplaycolor(ui): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
361 ui = ui.copy() |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
362 ui._styles.clear() |
31689
57a22f699179
color: stop mutating the default effects map
Matt Harbison <matt_harbison@yahoo.com>
parents:
31634
diff
changeset
|
363 for effect in color._activeeffects(ui).keys(): |
31121
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
364 ui._styles[effect] = effect |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
365 if ui._terminfoparams: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
366 for k, v in ui.configitems('color'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
367 if k.startswith('color.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
368 ui._styles[k] = k[6:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
369 elif k.startswith('terminfo.'): |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
370 ui._styles[k] = k[9:] |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
371 ui.write(_('available colors:\n')) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
372 # sort label with a '_' after the other to group '_background' entry. |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
373 items = sorted(ui._styles.items(), |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
374 key=lambda i: ('_' in i[0], i[0], i[1])) |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
375 for colorname, label in items: |
8fc55bbd2235
color: cleanup 'debugcolor' logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31120
diff
changeset
|
376 ui.write(('%s\n') % colorname, label=label) |
31120
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
377 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
378 def _debugdisplaystyle(ui): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
379 ui.write(_('available style:\n')) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
380 width = max(len(s) for s in ui._styles) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
381 for label, effects in sorted(ui._styles.items()): |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
382 ui.write('%s' % label, label=label) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
383 if effects: |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
384 # 50 |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
385 ui.write(': ') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
386 ui.write(' ' * (max(0, width - len(label)))) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
387 ui.write(', '.join(ui.label(e, e) for e in effects.split())) |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
388 ui.write('\n') |
c4e8fa2b1c40
color: move 'debugcolor' into the 'debugcommands' modules
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31074
diff
changeset
|
389 |
30504
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
390 @command('debugcommands', [], _('[COMMAND]'), norepo=True) |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
391 def debugcommands(ui, cmd='', *args): |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
392 """list all available commands and options""" |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
393 for cmd, vals in sorted(commands.table.iteritems()): |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
394 cmd = cmd.split('|')[0].strip('^') |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
395 opts = ', '.join([i[1] for i in vals[1]]) |
c3bdc27121d1
debugcommands: move 'debugcommands' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30503
diff
changeset
|
396 ui.write('%s: %s\n' % (cmd, opts)) |
30505
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
397 |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
398 @command('debugcomplete', |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
399 [('o', 'options', None, _('show the command options'))], |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
400 _('[-o] CMD'), |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
401 norepo=True) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
402 def debugcomplete(ui, cmd='', **opts): |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
403 """returns the completion list associated with the given command""" |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
404 |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
405 if opts.get('options'): |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
406 options = [] |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
407 otables = [commands.globalopts] |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
408 if cmd: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
409 aliases, entry = cmdutil.findcmd(cmd, commands.table, False) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
410 otables.append(entry[1]) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
411 for t in otables: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
412 for o in t: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
413 if "(DEPRECATED)" in o[3]: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
414 continue |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
415 if o[0]: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
416 options.append('-%s' % o[0]) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
417 options.append('--%s' % o[1]) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
418 ui.write("%s\n" % "\n".join(options)) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
419 return |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
420 |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
421 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, commands.table) |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
422 if ui.verbose: |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
423 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
158b41842fd2
debugcommands: move 'debugcomplete' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30504
diff
changeset
|
424 ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
425 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
426 @command('debugcreatestreamclonebundle', [], 'FILE') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
427 def debugcreatestreamclonebundle(ui, repo, fname): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
428 """create a stream clone bundle file |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
429 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
430 Stream bundles are special bundles that are essentially archives of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
431 revlog files. They are commonly used for cloning very quickly. |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
432 """ |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
433 requirements, gen = streamclone.generatebundlev1(repo) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
434 changegroup.writechunks(ui, gen, fname) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
435 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
436 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
437 |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
438 @command('debugdag', |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
439 [('t', 'tags', None, _('use tags as labels')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
440 ('b', 'branches', None, _('annotate with branch names')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
441 ('', 'dots', None, _('use dots for runs')), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
442 ('s', 'spaces', None, _('separate elements by spaces'))], |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
443 _('[OPTION]... [FILE [REV]...]'), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
444 optionalrepo=True) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
445 def debugdag(ui, repo, file_=None, *revs, **opts): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
446 """format the changelog or an index DAG as a concise textual description |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
447 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
448 If you pass a revlog index, the revlog's DAG is emitted. If you list |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
449 revision numbers, they get labeled in the output as rN. |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
450 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
451 Otherwise, the changelog DAG of the current repo is emitted. |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
452 """ |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
453 spaces = opts.get('spaces') |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
454 dots = opts.get('dots') |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
455 if file_: |
31239
9cdba6072b97
vfs: use 'vfs' module directly in 'mercurial.debugcommand'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
456 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), |
30519
20a42325fdef
py3: use pycompat.getcwd() instead of os.getcwd()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30518
diff
changeset
|
457 file_) |
30514
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
458 revs = set((int(r) for r in revs)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
459 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
460 for r in rlog: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
461 yield 'n', (r, list(p for p in rlog.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
462 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
463 if r in revs: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
464 yield 'l', (r, "r%i" % r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
465 elif repo: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
466 cl = repo.changelog |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
467 tags = opts.get('tags') |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
468 branches = opts.get('branches') |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
469 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
470 labels = {} |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
471 for l, n in repo.tags().items(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
472 labels.setdefault(cl.rev(n), []).append(l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
473 def events(): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
474 b = "default" |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
475 for r in cl: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
476 if branches: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
477 newb = cl.read(cl.node(r))[5]['branch'] |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
478 if newb != b: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
479 yield 'a', newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
480 b = newb |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
481 yield 'n', (r, list(p for p in cl.parentrevs(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
482 if p != -1)) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
483 if tags: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
484 ls = labels.get(r) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
485 if ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
486 for l in ls: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
487 yield 'l', (r, l) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
488 else: |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
489 raise error.Abort(_('need repo for changelog dag')) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
490 |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
491 for line in dagparser.dagtextlines(events(), |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
492 addspaces=spaces, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
493 wraplabels=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
494 wrapannotations=True, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
495 wrapnonlinear=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
496 usedots=dots, |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
497 maxlinewidth=70): |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
498 ui.write(line) |
625ccc95fa96
debugcommands: move 'debugdag' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30505
diff
changeset
|
499 ui.write("\n") |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
500 |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
501 @command('debugdata', commands.debugrevlogopts, _('-c|-m|FILE REV')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
502 def debugdata(ui, repo, file_, rev=None, **opts): |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
503 """dump the contents of a data file revision""" |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
504 if opts.get('changelog') or opts.get('manifest') or opts.get('dir'): |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
505 if rev is not None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
506 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
507 file_, rev = None, file_ |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
508 elif rev is None: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
509 raise error.CommandError('debugdata', _('invalid arguments')) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
510 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts) |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
511 try: |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30541
diff
changeset
|
512 ui.write(r.revision(r.lookup(rev), raw=True)) |
30515
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
513 except KeyError: |
cdd1885d0f2f
debugcommands: move 'debugrevlogopts' into the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30514
diff
changeset
|
514 raise error.Abort(_('invalid revision identifier %s') % rev) |
30516
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
515 |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
516 @command('debugdate', |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
517 [('e', 'extended', None, _('try extended date formats'))], |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
518 _('[-e] DATE [RANGE]'), |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
519 norepo=True, optionalrepo=True) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
520 def debugdate(ui, date, range=None, **opts): |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
521 """parse and display a date""" |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
522 if opts["extended"]: |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
523 d = util.parsedate(date, util.extendeddateformats) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
524 else: |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
525 d = util.parsedate(date) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
526 ui.write(("internal: %s %s\n") % d) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
527 ui.write(("standard: %s\n") % util.datestr(d)) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
528 if range: |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
529 m = util.matchdate(range) |
ef1353c283e3
debugcommands: move 'debugdate' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30515
diff
changeset
|
530 ui.write(("match: %s\n") % m(d[0])) |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
531 |
30541
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
532 @command('debugdeltachain', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
533 commands.debugrevlogopts + commands.formatteropts, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
534 _('-c|-m|FILE'), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
535 optionalrepo=True) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
536 def debugdeltachain(ui, repo, file_=None, **opts): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
537 """dump information about delta chains in a revlog |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
538 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
539 Output can be templatized. Available template keywords are: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
540 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
541 :``rev``: revision number |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
542 :``chainid``: delta chain identifier (numbered by unique base) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
543 :``chainlen``: delta chain length to this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
544 :``prevrev``: previous revision in delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
545 :``deltatype``: role of delta / how it was computed |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
546 :``compsize``: compressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
547 :``uncompsize``: uncompressed size of revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
548 :``chainsize``: total size of compressed revisions in chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
549 :``chainratio``: total chain size divided by uncompressed revision size |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
550 (new delta chains typically start at ratio 2.00) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
551 :``lindist``: linear distance from base revision in delta chain to end |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
552 of this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
553 :``extradist``: total size of revisions not part of this delta chain from |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
554 base of delta chain to end of this revision; a measurement |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
555 of how much extra data we need to read/seek across to read |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
556 the delta chain for this revision |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
557 :``extraratio``: extradist divided by chainsize; another representation of |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
558 how much unrelated data is needed to load this delta chain |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
559 """ |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
560 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
561 index = r.index |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
562 generaldelta = r.version & revlog.REVLOGGENERALDELTA |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
563 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
564 def revinfo(rev): |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
565 e = index[rev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
566 compsize = e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
567 uncompsize = e[2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
568 chainsize = 0 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
569 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
570 if generaldelta: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
571 if e[3] == e[5]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
572 deltatype = 'p1' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
573 elif e[3] == e[6]: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
574 deltatype = 'p2' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
575 elif e[3] == rev - 1: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
576 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
577 elif e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
578 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
579 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
580 deltatype = 'other' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
581 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
582 if e[3] == rev: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
583 deltatype = 'base' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
584 else: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
585 deltatype = 'prev' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
586 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
587 chain = r._deltachain(rev)[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
588 for iterrev in chain: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
589 e = index[iterrev] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
590 chainsize += e[1] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
591 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
592 return compsize, uncompsize, deltatype, chain, chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
593 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
594 fm = ui.formatter('debugdeltachain', opts) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
595 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
596 fm.plain(' rev chain# chainlen prev delta ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
597 'size rawsize chainsize ratio lindist extradist ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
598 'extraratio\n') |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
599 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
600 chainbases = {} |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
601 for rev in r: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
602 comp, uncomp, deltatype, chain, chainsize = revinfo(rev) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
603 chainbase = chain[0] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
604 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
605 basestart = r.start(chainbase) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
606 revstart = r.start(rev) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
607 lineardist = revstart + comp - basestart |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
608 extradist = lineardist - chainsize |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
609 try: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
610 prevrev = chain[-2] |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
611 except IndexError: |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
612 prevrev = -1 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
613 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
614 chainratio = float(chainsize) / float(uncomp) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
615 extraratio = float(extradist) / float(chainsize) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
616 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
617 fm.startitem() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
618 fm.write('rev chainid chainlen prevrev deltatype compsize ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
619 'uncompsize chainsize chainratio lindist extradist ' |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
620 'extraratio', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
621 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n', |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
622 rev, chainid, len(chain), prevrev, deltatype, comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
623 uncomp, chainsize, chainratio, lineardist, extradist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
624 extraratio, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
625 rev=rev, chainid=chainid, chainlen=len(chain), |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
626 prevrev=prevrev, deltatype=deltatype, compsize=comp, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
627 uncompsize=uncomp, chainsize=chainsize, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
628 chainratio=chainratio, lindist=lineardist, |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
629 extradist=extradist, extraratio=extraratio) |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
630 |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
631 fm.end() |
342d0cb4f446
debugcommands: sort command order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30529
diff
changeset
|
632 |
30954
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
633 @command('debugdirstate|debugstate', |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
634 [('', '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:
30953
diff
changeset
|
635 ('', 'datesort', None, _('sort by saved mtime'))], |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
636 _('[OPTION]...')) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
637 def debugstate(ui, repo, **opts): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
638 """show the contents of the current dirstate""" |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
639 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
640 nodates = opts.get('nodates') |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
641 datesort = opts.get('datesort') |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
642 |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
643 timestr = "" |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
644 if datesort: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
645 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
646 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
647 keyfunc = None # sort by filename |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
648 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
649 if ent[3] == -1: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
650 timestr = 'unset ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
651 elif nodates: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
652 timestr = 'set ' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
653 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
654 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
655 time.localtime(ent[3])) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
656 if ent[1] & 0o20000: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
657 mode = 'lnk' |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
658 else: |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
659 mode = '%3o' % (ent[1] & 0o777 & ~util.umask) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
660 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
661 for f in repo.dirstate.copies(): |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
662 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
dad968920130
debugcommands: move 'debugstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30953
diff
changeset
|
663 |
30517
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
664 @command('debugdiscovery', |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
665 [('', 'old', None, _('use old-style discovery')), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
666 ('', 'nonheads', None, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
667 _('use old-style discovery with non-heads included')), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
668 ] + commands.remoteopts, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
669 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
670 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
671 """runs the changeset discovery protocol in isolation""" |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
672 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
673 opts.get('branch')) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
674 remote = hg.peer(repo, opts, remoteurl) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
675 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
676 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
677 # make sure tests are repeatable |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
678 random.seed(12323) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
679 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
680 def doit(localheads, remoteheads, remote=remote): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
681 if opts.get('old'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
682 if localheads: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
683 raise error.Abort('cannot use localheads with old style ' |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
684 'discovery') |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
685 if not util.safehasattr(remote, 'branches'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
686 # enable in-client legacy support |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
687 remote = localrepo.locallegacypeer(remote.local()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
688 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
689 force=True) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
690 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
691 if not opts.get('nonheads'): |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
692 ui.write(("unpruned common: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
693 " ".join(sorted(short(n) for n in common))) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
694 dag = dagutil.revlogdag(repo.changelog) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
695 all = dag.ancestorset(dag.internalizeall(common)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
696 common = dag.externalizeall(dag.headsetofconnecteds(all)) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
697 else: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
698 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
699 common = set(common) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
700 rheads = set(hds) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
701 lheads = set(repo.heads()) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
702 ui.write(("common heads: %s\n") % |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
703 " ".join(sorted(short(n) for n in common))) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
704 if lheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
705 ui.write(("local is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
706 elif rheads <= common: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
707 ui.write(("remote is subset\n")) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
708 |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
709 serverlogs = opts.get('serverlog') |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
710 if serverlogs: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
711 for filename in serverlogs: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
712 with open(filename, 'r') as logfile: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
713 line = logfile.readline() |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
714 while line: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
715 parts = line.strip().split(';') |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
716 op = parts[1] |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
717 if op == 'cg': |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
718 pass |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
719 elif op == 'cgss': |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
720 doit(parts[2].split(' '), parts[3].split(' ')) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
721 elif op == 'unb': |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
722 doit(parts[3].split(' '), parts[2].split(' ')) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
723 line = logfile.readline() |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
724 else: |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
725 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
726 opts.get('remote_head')) |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
727 localrevs = opts.get('local_head') |
a3ec6db36315
debugcommands: move 'debugdiscovery' in the module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30516
diff
changeset
|
728 doit(localrevs, remoterevs) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
729 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
730 @command('debugextensions', commands.formatteropts, [], norepo=True) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
731 def debugextensions(ui, **opts): |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
732 '''show information about active extensions''' |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
733 exts = extensions.extensions(ui) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
734 hgver = util.version() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
735 fm = ui.formatter('debugextensions', opts) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
736 for extname, extmod in sorted(exts, key=operator.itemgetter(0)): |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
737 isinternal = extensions.ismoduleinternal(extmod) |
31074
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31024
diff
changeset
|
738 extsource = pycompat.fsencode(extmod.__file__) |
30518
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
739 if isinternal: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
740 exttestedwith = [] # never expose magic string to users |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
741 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
742 exttestedwith = getattr(extmod, 'testedwith', '').split() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
743 extbuglink = getattr(extmod, 'buglink', None) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
744 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
745 fm.startitem() |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
746 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
747 if ui.quiet or ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
748 fm.write('name', '%s\n', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
749 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
750 fm.write('name', '%s', extname) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
751 if isinternal or hgver in exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
752 fm.plain('\n') |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
753 elif not exttestedwith: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
754 fm.plain(_(' (untested!)\n')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
755 else: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
756 lasttestedversion = exttestedwith[-1] |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
757 fm.plain(' (%s!)\n' % lasttestedversion) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
758 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
759 fm.condwrite(ui.verbose and extsource, 'source', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
760 _(' location: %s\n'), extsource or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
761 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
762 if ui.verbose: |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
763 fm.plain(_(' bundled: %s\n') % ['no', 'yes'][isinternal]) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
764 fm.data(bundled=isinternal) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
765 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
766 fm.condwrite(ui.verbose and exttestedwith, 'testedwith', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
767 _(' tested with: %s\n'), |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
768 fm.formatlist(exttestedwith, name='ver')) |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
769 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
770 fm.condwrite(ui.verbose and extbuglink, 'buglink', |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
771 _(' bug reporting: %s\n'), extbuglink or "") |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
772 |
a8b17859684a
debugcommands: move 'debugextensions' to the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30517
diff
changeset
|
773 fm.end() |
30524
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
774 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
775 @command('debugfileset', |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
776 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
777 _('[-r REV] FILESPEC')) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
778 def debugfileset(ui, repo, expr, **opts): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
779 '''parse and apply a fileset specification''' |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
780 ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
781 if ui.verbose: |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
782 tree = fileset.parse(expr) |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
783 ui.note(fileset.prettyformat(tree), "\n") |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
784 |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
785 for f in ctx.getfileset(expr): |
1ee358c3ed26
debugcommands: move 'debugfileset' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30519
diff
changeset
|
786 ui.write("%s\n" % f) |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
787 |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
788 @command('debugfsinfo', [], _('[PATH]'), norepo=True) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
789 def debugfsinfo(ui, path="."): |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
790 """show information detected about current filesystem""" |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
791 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no')) |
31633
5b3d55a6821f
debugfsinfo: show fstype for given path
Jun Wu <quark@fb.com>
parents:
31595
diff
changeset
|
792 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
30525
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
793 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
86ebd2f61c31
debugcommands: move 'debugfsinfo' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30524
diff
changeset
|
794 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
31634
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
795 casesensitive = '(unknown)' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
796 try: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
797 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
798 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
799 except OSError: |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
800 pass |
35738db2037a
debugfsinfo: improve case-sensitive testing
Jun Wu <quark@fb.com>
parents:
31633
diff
changeset
|
801 ui.write(('case-sensitive: %s\n') % casesensitive) |
30526
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
802 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
803 @command('debuggetbundle', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
804 [('H', 'head', [], _('id of head node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
805 ('C', 'common', [], _('id of common node'), _('ID')), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
806 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))], |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
807 _('REPO FILE [-H|-C ID]...'), |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
808 norepo=True) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
809 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
810 """retrieves a bundle from a repo |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
811 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
812 Every ID must be a full-length hex node id string. Saves the bundle to the |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
813 given file. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
814 """ |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
815 repo = hg.peer(ui, opts, repopath) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
816 if not repo.capable('getbundle'): |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
817 raise error.Abort("getbundle() not supported by target repository") |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
818 args = {} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
819 if common: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
820 args['common'] = [bin(s) for s in common] |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
821 if head: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
822 args['heads'] = [bin(s) for s in head] |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
823 # TODO: get desired bundlecaps from command line. |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
824 args['bundlecaps'] = None |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
825 bundle = repo.getbundle('debug', **args) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
826 |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
827 bundletype = opts.get('type', 'bzip2').lower() |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
828 btypes = {'none': 'HG10UN', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
829 'bzip2': 'HG10BZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
830 'gzip': 'HG10GZ', |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
831 'bundle2': 'HG20'} |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
832 bundletype = btypes.get(bundletype) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
833 if bundletype not in bundle2.bundletypes: |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
834 raise error.Abort(_('unknown bundle type specified with --type')) |
9c10905f4b48
debugcommands: move 'debuggetbundle' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30525
diff
changeset
|
835 bundle2.writebundle(ui, bundle, bundlepath, bundletype) |
30527
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
836 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
837 @command('debugignore', [], '[FILE]') |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
838 def debugignore(ui, repo, *files, **opts): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
839 """display the combined ignore pattern and information about ignored files |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
840 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
841 With no argument display the combined ignore pattern. |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
842 |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
843 Given space separated file names, shows if the given file is ignored and |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
844 if so, show the ignore rule (file and line number) that matched it. |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
845 """ |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
846 ignore = repo.dirstate._ignore |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
847 if not files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
848 # Show all the patterns |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
849 includepat = getattr(ignore, 'includepat', None) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
850 if includepat is not None: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
851 ui.write("%s\n" % includepat) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
852 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
853 raise error.Abort(_("no ignore patterns found")) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
854 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
855 for f in files: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
856 nf = util.normpath(f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
857 ignored = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
858 ignoredata = None |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
859 if nf != '.': |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
860 if ignore(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
861 ignored = nf |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
862 ignoredata = repo.dirstate._ignorefileandline(nf) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
863 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
864 for p in util.finddirs(nf): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
865 if ignore(p): |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
866 ignored = p |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
867 ignoredata = repo.dirstate._ignorefileandline(p) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
868 break |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
869 if ignored: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
870 if ignored == nf: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
871 ui.write(_("%s is ignored\n") % f) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
872 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
873 ui.write(_("%s is ignored because of " |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
874 "containing folder %s\n") |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
875 % (f, ignored)) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
876 ignorefile, lineno, line = ignoredata |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
877 ui.write(_("(ignore rule in %s, line %d: '%s')\n") |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
878 % (ignorefile, lineno, line)) |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
879 else: |
243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30526
diff
changeset
|
880 ui.write(_("%s is not ignored\n") % f) |
30528
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
881 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
882 @command('debugindex', commands.debugrevlogopts + |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
883 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
884 _('[-f FORMAT] -c|-m|FILE'), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
885 optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
886 def debugindex(ui, repo, file_=None, **opts): |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
887 """dump the contents of an index file""" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
888 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
889 format = opts.get('format', 0) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
890 if format not in (0, 1): |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
891 raise error.Abort(_("unknown format %d") % format) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
892 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
893 generaldelta = r.version & revlog.REVLOGGENERALDELTA |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
894 if generaldelta: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
895 basehdr = ' delta' |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
896 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
897 basehdr = ' base' |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
898 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
899 if ui.debugflag: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
900 shortfn = hex |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
901 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
902 shortfn = short |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
903 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
904 # 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:
30527
diff
changeset
|
905 idlen = 12 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
906 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
907 idlen = len(shortfn(r.node(i))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
908 break |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
909 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
910 if format == 0: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
911 ui.write((" rev offset length " + basehdr + " linkrev" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
912 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
913 elif format == 1: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
914 ui.write((" rev flag offset length" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
915 " size " + basehdr + " link p1 p2" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
916 " %s\n") % "nodeid".rjust(idlen)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
917 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
918 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
919 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
920 if generaldelta: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
921 base = r.deltaparent(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
922 else: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
923 base = r.chainbase(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
924 if format == 0: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
925 try: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
926 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
927 except Exception: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
928 pp = [nullid, nullid] |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
929 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
930 i, r.start(i), r.length(i), base, r.linkrev(i), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
931 shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
932 elif format == 1: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
933 pr = r.parentrevs(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
934 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
935 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
936 base, r.linkrev(i), pr[0], pr[1], shortfn(node))) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
937 |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
938 @command('debugindexdot', commands.debugrevlogopts, |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
939 _('-c|-m|FILE'), optionalrepo=True) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
940 def debugindexdot(ui, repo, file_=None, **opts): |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
941 """dump an index DAG as a graphviz dot file""" |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
942 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
943 ui.write(("digraph G {\n")) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
944 for i in r: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
945 node = r.node(i) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
946 pp = r.parents(node) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
947 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
948 if pp[1] != nullid: |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
949 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30527
diff
changeset
|
950 ui.write("}\n") |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
951 |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
952 @command('debuginstall', [] + commands.formatteropts, '', norepo=True) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
953 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
|
954 '''test Mercurial installation |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
955 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
956 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
|
957 ''' |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
958 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
959 def writetemp(contents): |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
960 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
30988
d194f0dba7ac
py3: convert the mode argument of os.fdopen to unicodes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30959
diff
changeset
|
961 f = os.fdopen(fd, pycompat.sysstr("wb")) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
962 f.write(contents) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
963 f.close() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
964 return name |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
965 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
966 problems = 0 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
967 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
968 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
|
969 fm.startitem() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
970 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
971 # encoding |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
972 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
|
973 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
974 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
975 encoding.fromlocal("test") |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
976 except error.Abort as inst: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
977 err = inst |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
978 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
979 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
|
980 " (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
|
981 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
982 # Python |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
983 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
|
984 pycompat.sysexecutable) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
985 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
|
986 ("%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
|
987 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
|
988 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
|
989 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
990 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
|
991 if sslutil.hassni: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
992 security.add('sni') |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
993 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
994 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
|
995 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
|
996 fmt='%s', sep=',')) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
997 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
998 # 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
|
999 # 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
|
1000 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
|
1001 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
|
1002 '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
|
1003 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
|
1004 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
|
1005 '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
|
1006 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1007 # 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
|
1008 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1009 # hg version |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1010 hgver = util.version() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1011 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
|
1012 hgver.split('+')[0]) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1013 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
|
1014 '+'.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
|
1015 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1016 # compiled modules |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1017 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
|
1018 policy.policy) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1019 fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
31074
2912b06905dc
py3: use pycompat.fsencode() to convert __file__ to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
31024
diff
changeset
|
1020 os.path.dirname(pycompat.fsencode(__file__))) |
30918
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1021 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1022 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1023 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1024 from . import ( |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1025 base85, |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1026 bdiff, |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1027 mpatch, |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1028 osutil, |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1029 ) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1030 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1031 except Exception as inst: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1032 err = inst |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1033 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1034 fm.condwrite(err, 'extensionserror', " %s\n", err) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1035 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 '(%s)\n'), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1042 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
|
1043 if e.available()), |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1044 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
|
1045 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
|
1046 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
|
1047 '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
|
1048 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
|
1049 if e.wireprotosupport()], |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1050 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
|
1051 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1052 # templates |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1053 p = templater.templatepaths() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1054 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
|
1055 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
|
1056 if p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1057 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
|
1058 if m: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1059 # 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
|
1060 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1061 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1062 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
|
1063 except Exception as inst: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1064 err = inst |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1065 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1066 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
|
1067 else: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1068 p = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1069 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
|
1070 _("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
|
1071 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
|
1072 _(" 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
|
1073 if not p: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1074 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1075 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
|
1076 _(" (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
|
1077 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1078 # editor |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1079 editor = ui.geteditor() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1080 editor = util.expandpath(editor) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1081 fm.write('editor', _("checking commit editor... (%s)\n"), editor) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1082 cmdpath = util.findexe(pycompat.shlexsplit(editor)[0]) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1083 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
|
1084 _(" 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
|
1085 " (specify a commit editor in your configuration" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1086 " file)\n"), not cmdpath and editor == 'vi' and editor) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1087 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
|
1088 _(" 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
|
1089 " (specify a commit editor in your configuration" |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1090 " file)\n"), not cmdpath and editor) |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1091 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
|
1092 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1093 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1094 # check username |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1095 username = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1096 err = None |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1097 try: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1098 username = ui.username() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1099 except error.Abort as e: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1100 err = e |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1101 problems += 1 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1102 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1103 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
|
1104 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
|
1105 " (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
|
1106 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1107 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
|
1108 _("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
|
1109 if not problems: |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1110 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
|
1111 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
|
1112 _("%d problems detected," |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1113 " 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
|
1114 fm.end() |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1115 |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1116 return problems |
fec3dbaa7f83
debugcommands: extract debuginstall in the debugcommands module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30775
diff
changeset
|
1117 |
30919
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1118 @command('debugknown', [], _('REPO ID...'), norepo=True) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1119 def debugknown(ui, repopath, *ids, **opts): |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1120 """test whether node ids are known to a repo |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1121 |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1122 Every ID must be a full-length hex node id string. Returns a list of 0s |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1123 and 1s indicating unknown/known. |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1124 """ |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1125 repo = hg.peer(ui, opts, repopath) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1126 if not repo.capable('known'): |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1127 raise error.Abort("known() not supported by target repository") |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1128 flags = repo.known([bin(s) for s in ids]) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1129 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) |
e1fa5fe9f9d4
debugcommands: move 'debugknown' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30918
diff
changeset
|
1130 |
30935
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1131 @command('debuglabelcomplete', [], _('LABEL...')) |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1132 def debuglabelcomplete(ui, repo, *args): |
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1133 '''backwards compatibility with old bash completion scripts (DEPRECATED)''' |
31402
ea0395eec67b
debuglabelcomplete: fix to call debugnamecomplete in new location
Kyle Lippincott <spectral@google.com>
parents:
31239
diff
changeset
|
1134 debugnamecomplete(ui, repo, *args) |
30935
e46533c3201e
debugcommands: move 'debuglabelcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30919
diff
changeset
|
1135 |
30938
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1136 @command('debuglocks', |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1137 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')), |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1138 ('W', 'force-wlock', None, |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1139 _('free the working state lock (DANGEROUS)'))], |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1140 _('[OPTION]...')) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1141 def debuglocks(ui, repo, **opts): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1142 """show or modify state of locks |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1143 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1144 By default, this command will show which locks are held. This |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1145 includes the user and process holding the lock, the amount of time |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1146 the lock has been held, and the machine name where the process is |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1147 running if it's not local. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1148 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1149 Locks protect the integrity of Mercurial's data, so should be |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1150 treated with care. System crashes or other interruptions may cause |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1151 locks to not be properly released, though Mercurial will usually |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1152 detect and remove such stale locks automatically. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1153 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1154 However, detecting stale locks may not always be possible (for |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1155 instance, on a shared filesystem). Removing locks may also be |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1156 blocked by filesystem permissions. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1157 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1158 Returns 0 if no locks are held. |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1159 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1160 """ |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1161 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1162 if opts.get('force_lock'): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1163 repo.svfs.unlink('lock') |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1164 if opts.get('force_wlock'): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1165 repo.vfs.unlink('wlock') |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1166 if opts.get('force_lock') or opts.get('force_lock'): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1167 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1168 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1169 now = time.time() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1170 held = 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1171 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1172 def report(vfs, name, method): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1173 # this causes stale locks to get reaped for more accurate reporting |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1174 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1175 l = method(False) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1176 except error.LockHeld: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1177 l = None |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1178 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1179 if l: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1180 l.release() |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1181 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1182 try: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1183 stat = vfs.lstat(name) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1184 age = now - stat.st_mtime |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1185 user = util.username(stat.st_uid) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1186 locker = vfs.readlock(name) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1187 if ":" in locker: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1188 host, pid = locker.split(':') |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1189 if host == socket.gethostname(): |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1190 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:
30937
diff
changeset
|
1191 else: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1192 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:
30937
diff
changeset
|
1193 % (user, pid, host) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1194 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1195 return 1 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1196 except OSError as e: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1197 if e.errno != errno.ENOENT: |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1198 raise |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1199 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1200 ui.write(("%-6s free\n") % (name + ":")) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1201 return 0 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1202 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1203 held += report(repo.svfs, "lock", repo.lock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1204 held += report(repo.vfs, "wlock", repo.wlock) |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1205 |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1206 return held |
23c801570449
debugcommands: move 'debuglocks' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30937
diff
changeset
|
1207 |
30936
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1208 @command('debugmergestate', [], '') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1209 def debugmergestate(ui, repo, *args): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1210 """print merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1211 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1212 Use --verbose to print out information about whether v1 or v2 merge state |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1213 was chosen.""" |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1214 def _hashornull(h): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1215 if h == nullhex: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1216 return 'null' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1217 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1218 return h |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1219 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1220 def printrecords(version): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1221 ui.write(('* version %s records\n') % version) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1222 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1223 records = v1records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1224 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1225 records = v2records |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1226 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1227 for rtype, record in records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1228 # pretty print some record types |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1229 if rtype == 'L': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1230 ui.write(('local: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1231 elif rtype == 'O': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1232 ui.write(('other: %s\n') % record) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1233 elif rtype == 'm': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1234 driver, mdstate = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1235 ui.write(('merge driver: %s (state "%s")\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1236 % (driver, mdstate)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1237 elif rtype in 'FDC': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1238 r = record.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1239 f, state, hash, lfile, afile, anode, ofile = r[0:7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1240 if version == 1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1241 onode = 'not stored in v1 format' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1242 flags = r[7] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1243 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1244 onode, flags = r[7:9] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1245 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1246 % (f, rtype, state, _hashornull(hash))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1247 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags)) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1248 ui.write((' ancestor path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1249 % (afile, _hashornull(anode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1250 ui.write((' other path: %s (node %s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1251 % (ofile, _hashornull(onode))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1252 elif rtype == 'f': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1253 filename, rawextras = record.split('\0', 1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1254 extras = rawextras.split('\0') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1255 i = 0 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1256 extrastrings = [] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1257 while i < len(extras): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1258 extrastrings.append('%s = %s' % (extras[i], extras[i + 1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1259 i += 2 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1260 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1261 ui.write(('file extras: %s (%s)\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1262 % (filename, ', '.join(extrastrings))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1263 elif rtype == 'l': |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1264 labels = record.split('\0', 2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1265 labels = [l for l in labels if len(l) > 0] |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1266 ui.write(('labels:\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1267 ui.write((' local: %s\n' % labels[0])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1268 ui.write((' other: %s\n' % labels[1])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1269 if len(labels) > 2: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1270 ui.write((' base: %s\n' % labels[2])) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1271 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1272 ui.write(('unrecognized entry: %s\t%s\n') |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1273 % (rtype, record.replace('\0', '\t'))) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1274 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1275 # Avoid mergestate.read() since it may raise an exception for unsupported |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1276 # merge state records. We shouldn't be doing this, but this is OK since this |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1277 # command is pretty low-level. |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1278 ms = mergemod.mergestate(repo) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1279 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1280 # sort so that reasonable information is on top |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1281 v1records = ms._readrecordsv1() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1282 v2records = ms._readrecordsv2() |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1283 order = 'LOml' |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1284 def key(r): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1285 idx = order.find(r[0]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1286 if idx == -1: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1287 return (1, r[1]) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1288 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1289 return (0, idx) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1290 v1records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1291 v2records.sort(key=key) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1292 |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1293 if not v1records and not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1294 ui.write(('no merge state found\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1295 elif not v2records: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1296 ui.note(('no version 2 merge state\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1297 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1298 elif ms._v1v2match(v1records, v2records): |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1299 ui.note(('v1 and v2 states match: using v2\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1300 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1301 else: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1302 ui.note(('v1 and v2 states mismatch: using v1\n')) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1303 printrecords(1) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1304 if ui.verbose: |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1305 printrecords(2) |
8de38479d60b
debugcommands: move 'debugmergestate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30935
diff
changeset
|
1306 |
30937
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1307 @command('debugnamecomplete', [], _('NAME...')) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1308 def debugnamecomplete(ui, repo, *args): |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1309 '''complete "names" - tags, open branch names, bookmark names''' |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1310 |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1311 names = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1312 # since we previously only listed open branches, we will handle that |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1313 # specially (after this for loop) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1314 for name, ns in repo.names.iteritems(): |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1315 if name != 'branches': |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1316 names.update(ns.listnames(repo)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1317 names.update(tag for (tag, heads, tip, closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1318 in repo.branchmap().iterbranches() if not closed) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1319 completions = set() |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1320 if not args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1321 args = [''] |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1322 for a in args: |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1323 completions.update(n for n in names if n.startswith(a)) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1324 ui.write('\n'.join(sorted(completions))) |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1325 ui.write('\n') |
a9aa67ba3f96
debugcommands: move 'debugnamecomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30936
diff
changeset
|
1326 |
30939
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1327 @command('debugobsolete', |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1328 [('', 'flags', 0, _('markers flag')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1329 ('', 'record-parents', False, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1330 _('record parent information for the precursor')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1331 ('r', 'rev', [], _('display markers relevant to REV')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1332 ('', 'index', False, _('display index of the marker')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1333 ('', 'delete', [], _('delete markers specified by indices')), |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1334 ] + commands.commitopts2 + commands.formatteropts, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1335 _('[OBSOLETED [REPLACEMENT ...]]')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1336 def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1337 """create arbitrary obsolete marker |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1338 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1339 With no arguments, displays the list of obsolescence markers.""" |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1340 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1341 def parsenodeid(s): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1342 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1343 # We do not use revsingle/revrange functions here to accept |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1344 # arbitrary node identifiers, possibly not present in the |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1345 # local repository. |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1346 n = bin(s) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1347 if len(n) != len(nullid): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1348 raise TypeError() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1349 return n |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1350 except TypeError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1351 raise error.Abort('changeset references must be full hexadecimal ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1352 'node identifiers') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1353 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1354 if opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1355 indices = [] |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1356 for v in opts.get('delete'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1357 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1358 indices.append(int(v)) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1359 except ValueError: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1360 raise error.Abort(_('invalid index value: %r') % v, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1361 hint=_('use integers for indices')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1362 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1363 if repo.currenttransaction(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1364 raise error.Abort(_('cannot delete obsmarkers in the middle ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1365 'of transaction.')) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1366 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1367 with repo.lock(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1368 n = repair.deleteobsmarkers(repo.obsstore, indices) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1369 ui.write(_('deleted %i obsolescence markers\n') % n) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1370 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1371 return |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1372 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1373 if precursor is not None: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1374 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1375 raise error.Abort('cannot select revision when creating marker') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1376 metadata = {} |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1377 metadata['user'] = opts['user'] or ui.username() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1378 succs = tuple(parsenodeid(succ) for succ in successors) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1379 l = repo.lock() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1380 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1381 tr = repo.transaction('debugobsolete') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1382 try: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1383 date = opts.get('date') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1384 if date: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1385 date = util.parsedate(date) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1386 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1387 date = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1388 prec = parsenodeid(precursor) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1389 parents = None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1390 if opts['record_parents']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1391 if prec not in repo.unfiltered(): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1392 raise error.Abort('cannot used --record-parents on ' |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1393 'unknown changesets') |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1394 parents = repo.unfiltered()[prec].parents() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1395 parents = tuple(p.node() for p in parents) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1396 repo.obsstore.create(tr, prec, succs, opts['flags'], |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1397 parents=parents, date=date, |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1398 metadata=metadata) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1399 tr.close() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1400 except ValueError as exc: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1401 raise error.Abort(_('bad obsmarker input: %s') % exc) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1402 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1403 tr.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1404 finally: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1405 l.release() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1406 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1407 if opts['rev']: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1408 revs = scmutil.revrange(repo, opts['rev']) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1409 nodes = [repo[r].node() for r in revs] |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1410 markers = list(obsolete.getmarkers(repo, nodes=nodes)) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1411 markers.sort(key=lambda x: x._data) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1412 else: |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1413 markers = obsolete.getmarkers(repo) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1414 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1415 markerstoiter = markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1416 isrelevant = lambda m: True |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1417 if opts.get('rev') and opts.get('index'): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1418 markerstoiter = obsolete.getmarkers(repo) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1419 markerset = set(markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1420 isrelevant = lambda m: m in markerset |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1421 |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1422 fm = ui.formatter('debugobsolete', opts) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1423 for i, m in enumerate(markerstoiter): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1424 if not isrelevant(m): |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1425 # marker can be irrelevant when we're iterating over a set |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1426 # of markers (markerstoiter) which is bigger than the set |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1427 # of markers we want to display (markers) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1428 # this can happen if both --index and --rev options are |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1429 # provided and thus we need to iterate over all of the markers |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1430 # to get the correct indices, but only display the ones that |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1431 # are relevant to --rev value |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1432 continue |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1433 fm.startitem() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1434 ind = i if opts.get('index') else None |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1435 cmdutil.showmarker(fm, m, index=ind) |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1436 fm.end() |
9e39d196cdf5
debugcommands: move 'debugobsolete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30938
diff
changeset
|
1437 |
30940
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1438 @command('debugpathcomplete', |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1439 [('f', 'full', None, _('complete an entire path')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1440 ('n', 'normal', None, _('show only normal files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1441 ('a', 'added', None, _('show only added files')), |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1442 ('r', 'removed', None, _('show only removed files'))], |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1443 _('FILESPEC...')) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1444 def debugpathcomplete(ui, repo, *specs, **opts): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1445 '''complete part or all of a tracked path |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1446 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1447 This command supports shells that offer path name completion. It |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1448 currently completes only files already known to the dirstate. |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1449 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1450 Completion extends only to the next path segment unless |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1451 --full is specified, in which case entire paths are used.''' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1452 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1453 def complete(path, acceptable): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1454 dirstate = repo.dirstate |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1455 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:
30939
diff
changeset
|
1456 rootdir = repo.root + pycompat.ossep |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1457 if spec != repo.root and not spec.startswith(rootdir): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1458 return [], [] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1459 if os.path.isdir(spec): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1460 spec += '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1461 spec = spec[len(rootdir):] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1462 fixpaths = pycompat.ossep != '/' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1463 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1464 spec = spec.replace(pycompat.ossep, '/') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1465 speclen = len(spec) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1466 fullpaths = opts['full'] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1467 files, dirs = set(), set() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1468 adddir, addfile = dirs.add, files.add |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1469 for f, st in dirstate.iteritems(): |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1470 if f.startswith(spec) and st[0] in acceptable: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1471 if fixpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1472 f = f.replace('/', pycompat.ossep) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1473 if fullpaths: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1474 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1475 continue |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1476 s = f.find(pycompat.ossep, speclen) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1477 if s >= 0: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1478 adddir(f[:s]) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1479 else: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1480 addfile(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1481 return files, dirs |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1482 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1483 acceptable = '' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1484 if opts['normal']: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1485 acceptable += 'nm' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1486 if opts['added']: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1487 acceptable += 'a' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1488 if opts['removed']: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1489 acceptable += 'r' |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1490 cwd = repo.getcwd() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1491 if not specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1492 specs = ['.'] |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1493 |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1494 files, dirs = set(), set() |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1495 for spec in specs: |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1496 f, d = complete(spec, acceptable or 'nmar') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1497 files.update(f) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1498 dirs.update(d) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1499 files.update(dirs) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1500 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1501 ui.write('\n') |
c8081ea63591
debugcommands: move 'debugpathcomplete' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30939
diff
changeset
|
1502 |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1503 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1504 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1505 '''access the pushkey key/value protocol |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1506 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1507 With two args, list the keys in the given namespace. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1508 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1509 With five args, set a key to new if it currently is set to old. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1510 Reports success or failure. |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1511 ''' |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1512 |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1513 target = hg.peer(ui, {}, repopath) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1514 if keyinfo: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1515 key, old, new = keyinfo |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1516 r = target.pushkey(namespace, key, old, new) |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1517 ui.status(str(r) + '\n') |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1518 return not r |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1519 else: |
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1520 for k, v in sorted(target.listkeys(namespace).iteritems()): |
31451
53865692a354
util: wrap s.encode('string_escape') call for future py3 compatibility
Yuya Nishihara <yuya@tcha.org>
parents:
31402
diff
changeset
|
1521 ui.write("%s\t%s\n" % (util.escapestr(k), |
53865692a354
util: wrap s.encode('string_escape') call for future py3 compatibility
Yuya Nishihara <yuya@tcha.org>
parents:
31402
diff
changeset
|
1522 util.escapestr(v))) |
30946
7103122495e2
debugcommands: move 'debugpushkey' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30940
diff
changeset
|
1523 |
30947
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1524 @command('debugpvec', [], _('A B')) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1525 def debugpvec(ui, repo, a, b=None): |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1526 ca = scmutil.revsingle(repo, a) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1527 cb = scmutil.revsingle(repo, b) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1528 pa = pvec.ctxpvec(ca) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1529 pb = pvec.ctxpvec(cb) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1530 if pa == pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1531 rel = "=" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1532 elif pa > pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1533 rel = ">" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1534 elif pa < pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1535 rel = "<" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1536 elif pa | pb: |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1537 rel = "|" |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1538 ui.write(_("a: %s\n") % pa) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1539 ui.write(_("b: %s\n") % pb) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1540 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1541 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") % |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1542 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec), |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1543 pa.distance(pb), rel)) |
3c766ca89377
debugcommands: move 'debugpvec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30946
diff
changeset
|
1544 |
30948
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1545 @command('debugrebuilddirstate|debugrebuildstate', |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1546 [('r', 'rev', '', _('revision to rebuild to'), _('REV')), |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1547 ('', 'minimal', None, _('only rebuild files that are inconsistent with ' |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1548 'the working copy parent')), |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1549 ], |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1550 _('[-r REV]')) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1551 def debugrebuilddirstate(ui, repo, rev, **opts): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1552 """rebuild the dirstate as it would look like for the given revision |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1553 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1554 If no revision is specified the first current parent will be used. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1555 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1556 The dirstate will be set to the files of the given revision. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1557 The actual working directory content or existing dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1558 information such as adds or removes is not considered. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1559 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1560 ``minimal`` will only rebuild the dirstate status for files that claim to be |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1561 tracked but are not in the parent manifest, or that exist in the parent |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1562 manifest but are not in the dirstate. It will not change adds, removes, or |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1563 modified files that are in the working copy parent. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1564 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1565 One use of this command is to make the next :hg:`status` invocation |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1566 check the actual file content. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1567 """ |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1568 ctx = scmutil.revsingle(repo, rev) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1569 with repo.wlock(): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1570 dirstate = repo.dirstate |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1571 changedfiles = None |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1572 # See command doc for what minimal does. |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1573 if opts.get('minimal'): |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1574 manifestfiles = set(ctx.manifest().keys()) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1575 dirstatefiles = set(dirstate) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1576 manifestonly = manifestfiles - dirstatefiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1577 dsonly = dirstatefiles - manifestfiles |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1578 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1579 changedfiles = manifestonly | dsnotadded |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1580 |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1581 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) |
cc2b537b1966
debugcommands: move 'debugrebuilddirstate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30947
diff
changeset
|
1582 |
30949
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
1583 @command('debugrebuildfncache', [], '') |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
1584 def debugrebuildfncache(ui, repo): |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
1585 """rebuild the fncache file""" |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
1586 repair.rebuildfncache(ui, repo) |
e7d7335819f4
debugcommands: move 'debugrebuildfncache' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30948
diff
changeset
|
1587 |
30950
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1588 @command('debugrename', |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1589 [('r', 'rev', '', _('revision to debug'), _('REV'))], |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1590 _('[-r REV] FILE')) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1591 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:
30949
diff
changeset
|
1592 """dump rename information""" |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1593 |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1594 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:
30949
diff
changeset
|
1595 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:
30949
diff
changeset
|
1596 for abs in ctx.walk(m): |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1597 fctx = ctx[abs] |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1598 o = fctx.filelog().renamed(fctx.filenode()) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1599 rel = m.rel(abs) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1600 if o: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1601 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1602 else: |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1603 ui.write(_("%s not renamed\n") % rel) |
7236f949ce3f
debugcommands: move 'debugrename' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30949
diff
changeset
|
1604 |
30951
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1605 @command('debugrevlog', commands.debugrevlogopts + |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1606 [('d', 'dump', False, _('dump index data'))], |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1607 _('-c|-m|FILE'), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1608 optionalrepo=True) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1609 def debugrevlog(ui, repo, file_=None, **opts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1610 """show data and statistics about a revlog""" |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1611 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1612 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1613 if opts.get("dump"): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1614 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1615 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1616 " rawsize totalsize compression heads chainlen\n")) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1617 ts = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1618 heads = set() |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1619 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1620 for rev in xrange(numrevs): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1621 dbase = r.deltaparent(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1622 if dbase == -1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1623 dbase = rev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1624 cbase = r.chainbase(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1625 clen = r.chainlen(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1626 p1, p2 = r.parentrevs(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1627 rs = r.rawsize(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1628 ts = ts + rs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1629 heads -= set(r.parentrevs(rev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1630 heads.add(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1631 try: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1632 compression = ts / r.end(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1633 except ZeroDivisionError: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1634 compression = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1635 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1636 "%11d %5d %8d\n" % |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1637 (rev, p1, p2, r.start(rev), r.end(rev), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1638 r.start(dbase), r.start(cbase), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1639 r.start(p1), r.start(p2), |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1640 rs, ts, compression, len(heads), clen)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1641 return 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1642 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1643 v = r.version |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1644 format = v & 0xFFFF |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1645 flags = [] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1646 gdelta = False |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1647 if v & revlog.REVLOGNGINLINEDATA: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1648 flags.append('inline') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1649 if v & revlog.REVLOGGENERALDELTA: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1650 gdelta = True |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1651 flags.append('generaldelta') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1652 if not flags: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1653 flags = ['(none)'] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1654 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1655 nummerges = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1656 numfull = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1657 numprev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1658 nump1 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1659 nump2 = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1660 numother = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1661 nump1prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1662 nump2prev = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1663 chainlengths = [] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1664 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1665 datasize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1666 fullsize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1667 deltasize = [None, 0, 0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1668 chunktypecounts = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1669 chunktypesizes = {} |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1670 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1671 def addsize(size, l): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1672 if l[0] is None or size < l[0]: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1673 l[0] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1674 if size > l[1]: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1675 l[1] = size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1676 l[2] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1677 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1678 numrevs = len(r) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1679 for rev in xrange(numrevs): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1680 p1, p2 = r.parentrevs(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1681 delta = r.deltaparent(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1682 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1683 addsize(r.rawsize(rev), datasize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1684 if p2 != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1685 nummerges += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1686 size = r.length(rev) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1687 if delta == nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1688 chainlengths.append(0) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1689 numfull += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1690 addsize(size, fullsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1691 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1692 chainlengths.append(chainlengths[delta] + 1) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1693 addsize(size, deltasize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1694 if delta == rev - 1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1695 numprev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1696 if delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1697 nump1prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1698 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1699 nump2prev += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1700 elif delta == p1: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1701 nump1 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1702 elif delta == p2: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1703 nump2 += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1704 elif delta != nullrev: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1705 numother += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1706 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1707 # Obtain data on the raw chunks in the revlog. |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1708 chunk = r._chunkraw(rev, rev)[1] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1709 if chunk: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1710 chunktype = chunk[0] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1711 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1712 chunktype = 'empty' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1713 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1714 if chunktype not in chunktypecounts: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1715 chunktypecounts[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1716 chunktypesizes[chunktype] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1717 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1718 chunktypecounts[chunktype] += 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1719 chunktypesizes[chunktype] += size |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1720 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1721 # 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:
30950
diff
changeset
|
1722 for size in (datasize, fullsize, deltasize): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1723 if size[0] is None: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1724 size[0] = 0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1725 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1726 numdeltas = numrevs - numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1727 numoprev = numprev - nump1prev - nump2prev |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1728 totalrawsize = datasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1729 datasize[2] /= numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1730 fulltotal = fullsize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1731 fullsize[2] /= numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1732 deltatotal = deltasize[2] |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1733 if numrevs - numfull > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1734 deltasize[2] /= numrevs - numfull |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1735 totalsize = fulltotal + deltatotal |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1736 avgchainlen = sum(chainlengths) / numrevs |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1737 maxchainlen = max(chainlengths) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1738 compratio = 1 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1739 if totalsize: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1740 compratio = totalrawsize / totalsize |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1741 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1742 basedfmtstr = '%%%dd\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1743 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1744 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1745 def dfmtstr(max): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1746 return basedfmtstr % len(str(max)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1747 def pcfmtstr(max, padding=0): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1748 return basepcfmtstr % (len(str(max)), ' ' * padding) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1749 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1750 def pcfmt(value, total): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1751 if total: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1752 return (value, 100 * float(value) / total) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1753 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1754 return value, 100.0 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1755 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1756 ui.write(('format : %d\n') % format) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1757 ui.write(('flags : %s\n') % ', '.join(flags)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1758 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1759 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1760 fmt = pcfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1761 fmt2 = dfmtstr(totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1762 ui.write(('revisions : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1763 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1764 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1765 ui.write(('revisions : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1766 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:
30950
diff
changeset
|
1767 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1768 ui.write(('revision size : ') + fmt2 % totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1769 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:
30950
diff
changeset
|
1770 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1771 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1772 def fmtchunktype(chunktype): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1773 if chunktype == 'empty': |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1774 return ' %s : ' % chunktype |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1775 elif chunktype in string.ascii_letters: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1776 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1777 else: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1778 return ' 0x%s : ' % hex(chunktype) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1779 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1780 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1781 ui.write(('chunks : ') + fmt2 % numrevs) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1782 for chunktype in sorted(chunktypecounts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1783 ui.write(fmtchunktype(chunktype)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1784 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1785 ui.write(('chunks size : ') + fmt2 % totalsize) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1786 for chunktype in sorted(chunktypecounts): |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1787 ui.write(fmtchunktype(chunktype)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1788 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1789 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1790 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1791 fmt = dfmtstr(max(avgchainlen, compratio)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1792 ui.write(('avg chain length : ') + fmt % avgchainlen) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1793 ui.write(('max chain length : ') + fmt % maxchainlen) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1794 ui.write(('compression ratio : ') + fmt % compratio) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1795 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1796 if format > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1797 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1798 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1799 % tuple(datasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1800 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1801 % tuple(fullsize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1802 ui.write(('delta size (min/max/avg) : %d / %d / %d\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1803 % tuple(deltasize)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1804 |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1805 if numdeltas > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1806 ui.write('\n') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1807 fmt = pcfmtstr(numdeltas) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1808 fmt2 = pcfmtstr(numdeltas, 4) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1809 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1810 if numprev > 0: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1811 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1812 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1813 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1814 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1815 ui.write((' other : ') + fmt2 % pcfmt(numoprev, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1816 numprev)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1817 if gdelta: |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1818 ui.write(('deltas against p1 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1819 + fmt % pcfmt(nump1, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1820 ui.write(('deltas against p2 : ') |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1821 + fmt % pcfmt(nump2, numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1822 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1823 numdeltas)) |
f44b96aef81b
debugcommands: move 'debugrevlog' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30950
diff
changeset
|
1824 |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1825 @command('debugrevspec', |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1826 [('', 'optimize', None, |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1827 _('print parsed tree after optimizing (DEPRECATED)')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1828 ('p', 'show-stage', [], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1829 _('print parsed tree at the given stage'), _('NAME')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1830 ('', 'no-optimized', False, _('evaluate tree without optimization')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1831 ('', 'verify-optimized', False, _('verify optimized result')), |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1832 ], |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1833 ('REVSPEC')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1834 def debugrevspec(ui, repo, expr, **opts): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1835 """parse and apply a revision specification |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1836 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1837 Use -p/--show-stage option to print the parsed tree at the given stages. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1838 Use -p all to print tree at every stage. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1839 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1840 Use --verify-optimized to compare the optimized result with the unoptimized |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1841 one. Returns 1 if the optimized result differs. |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1842 """ |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1843 stages = [ |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1844 ('parsed', lambda tree: tree), |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1845 ('expanded', lambda tree: revsetlang.expandaliases(ui, tree)), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1846 ('concatenated', revsetlang.foldconcat), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1847 ('analyzed', revsetlang.analyze), |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1848 ('optimized', revsetlang.optimize), |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1849 ] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1850 if opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1851 stages = stages[:-1] |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1852 if opts['verify_optimized'] and opts['no_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1853 raise error.Abort(_('cannot use --verify-optimized with ' |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1854 '--no-optimized')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1855 stagenames = set(n for n, f in stages) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1856 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1857 showalways = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1858 showchanged = set() |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1859 if ui.verbose and not opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1860 # show parsed tree by --verbose (deprecated) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1861 showalways.add('parsed') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1862 showchanged.update(['expanded', 'concatenated']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1863 if opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1864 showalways.add('optimized') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1865 if opts['show_stage'] and opts['optimize']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1866 raise error.Abort(_('cannot use --optimize with --show-stage')) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1867 if opts['show_stage'] == ['all']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1868 showalways.update(stagenames) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1869 else: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1870 for n in opts['show_stage']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1871 if n not in stagenames: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1872 raise error.Abort(_('invalid stage name: %s') % n) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1873 showalways.update(opts['show_stage']) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1874 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1875 treebystage = {} |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1876 printedtree = None |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1877 tree = revsetlang.parse(expr, lookup=repo.__contains__) |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1878 for n, f in stages: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1879 treebystage[n] = tree = f(tree) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1880 if n in showalways or (n in showchanged and tree != printedtree): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1881 if opts['show_stage'] or n != 'parsed': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1882 ui.write(("* %s:\n") % n) |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30988
diff
changeset
|
1883 ui.write(revsetlang.prettyformat(tree), "\n") |
30952
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1884 printedtree = tree |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1885 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1886 if opts['verify_optimized']: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1887 arevs = revset.makematcher(treebystage['analyzed'])(repo) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1888 brevs = revset.makematcher(treebystage['optimized'])(repo) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1889 if ui.verbose: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1890 ui.note(("* analyzed set:\n"), smartset.prettyformat(arevs), "\n") |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1891 ui.note(("* optimized set:\n"), smartset.prettyformat(brevs), "\n") |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1892 arevs = list(arevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1893 brevs = list(brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1894 if arevs == brevs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1895 return 0 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1896 ui.write(('--- analyzed\n'), label='diff.file_a') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1897 ui.write(('+++ optimized\n'), label='diff.file_b') |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1898 sm = difflib.SequenceMatcher(None, arevs, brevs) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1899 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:
30951
diff
changeset
|
1900 if tag in ('delete', 'replace'): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1901 for c in arevs[alo:ahi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1902 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:
30951
diff
changeset
|
1903 if tag in ('insert', 'replace'): |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1904 for c in brevs[blo:bhi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1905 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:
30951
diff
changeset
|
1906 if tag == 'equal': |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1907 for c in arevs[alo:ahi]: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1908 ui.write(' %s\n' % c) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1909 return 1 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1910 |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1911 func = revset.makematcher(tree) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1912 revs = func(repo) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1913 if ui.verbose: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1914 ui.note(("* set:\n"), smartset.prettyformat(revs), "\n") |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1915 for c in revs: |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1916 ui.write("%s\n" % c) |
85c3c879c43a
debugcommands: move 'debugrevspec' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30951
diff
changeset
|
1917 |
30953
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1918 @command('debugsetparents', [], _('REV1 [REV2]')) |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1919 def debugsetparents(ui, repo, rev1, rev2=None): |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1920 """manually set the parents of the current working directory |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1921 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1922 This is useful for writing repository conversion tools, but should |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1923 be used with care. For example, neither the working directory nor the |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1924 dirstate is updated, so file status may be incorrect after running this |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1925 command. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1926 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1927 Returns 0 on success. |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1928 """ |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1929 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1930 r1 = scmutil.revsingle(repo, rev1).node() |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1931 r2 = scmutil.revsingle(repo, rev2, 'null').node() |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1932 |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1933 with repo.wlock(): |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1934 repo.setparents(r1, r2) |
5b09e9bc0902
debugcommands: move 'debugsetparents' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30952
diff
changeset
|
1935 |
30955
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1936 @command('debugsub', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1937 [('r', 'rev', '', |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1938 _('revision to check'), _('REV'))], |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1939 _('[-r REV] [REV]')) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1940 def debugsub(ui, repo, rev=None): |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1941 ctx = scmutil.revsingle(repo, rev, None) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1942 for k, v in sorted(ctx.substate.items()): |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1943 ui.write(('path %s\n') % k) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1944 ui.write((' source %s\n') % v[0]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1945 ui.write((' revision %s\n') % v[1]) |
8e38fa360a12
debugcommands: move 'debugsub' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30954
diff
changeset
|
1946 |
30956
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1947 @command('debugsuccessorssets', |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1948 [], |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1949 _('[REV]')) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1950 def debugsuccessorssets(ui, repo, *revs): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1951 """show set of successors for revision |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1952 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1953 A successors set of changeset A is a consistent group of revisions that |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1954 succeed A. It contains non-obsolete changesets only. |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1955 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1956 In most cases a changeset A has a single successors set containing a single |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1957 successor (changeset A replaced by A'). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1958 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1959 A changeset that is made obsolete with no successors are called "pruned". |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1960 Such changesets have no successors sets at all. |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1961 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1962 A changeset that has been "split" will have a successors set containing |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1963 more than one successor. |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1964 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1965 A changeset that has been rewritten in multiple different ways is called |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1966 "divergent". Such changesets have multiple successor sets (each of which |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1967 may also be split, i.e. have multiple successors). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1968 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1969 Results are displayed as follows:: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1970 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1971 <rev1> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1972 <successors-1A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1973 <rev2> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1974 <successors-2A> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1975 <successors-2B1> <successors-2B2> <successors-2B3> |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1976 |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1977 Here rev2 has two possible (i.e. divergent) successors sets. The first |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1978 holds one element, whereas the second holds three (i.e. the changeset has |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1979 been split). |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1980 """ |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1981 # passed to successorssets caching computation from one call to another |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1982 cache = {} |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1983 ctx2str = str |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1984 node2str = short |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1985 if ui.debug(): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1986 def ctx2str(ctx): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1987 return ctx.hex() |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1988 node2str = hex |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1989 for rev in scmutil.revrange(repo, revs): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1990 ctx = repo[rev] |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1991 ui.write('%s\n'% ctx2str(ctx)) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1992 for succsset in obsolete.successorssets(repo, ctx.node(), cache): |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1993 if succsset: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1994 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1995 ui.write(node2str(succsset[0])) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1996 for node in succsset[1:]: |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1997 ui.write(' ') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1998 ui.write(node2str(node)) |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
1999 ui.write('\n') |
db30c6bfeb70
debugcommands: move 'debugsuccessorssets' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30955
diff
changeset
|
2000 |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2001 @command('debugtemplate', |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2002 [('r', 'rev', [], _('apply template on changesets'), _('REV')), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2003 ('D', 'define', [], _('define template keyword'), _('KEY=VALUE'))], |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2004 _('[-r REV]... [-D KEY=VALUE]... TEMPLATE'), |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2005 optionalrepo=True) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2006 def debugtemplate(ui, repo, tmpl, **opts): |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2007 """parse and apply a template |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2008 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2009 If -r/--rev is given, the template is processed as a log template and |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2010 applied to the given changesets. Otherwise, it is processed as a generic |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2011 template. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2012 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2013 Use --verbose to print the parsed tree. |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2014 """ |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2015 revs = None |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2016 if opts['rev']: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2017 if repo is None: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2018 raise error.RepoError(_('there is no Mercurial repository here ' |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2019 '(.hg not found)')) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2020 revs = scmutil.revrange(repo, opts['rev']) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2021 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2022 props = {} |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2023 for d in opts['define']: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2024 try: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2025 k, v = (e.strip() for e in d.split('=', 1)) |
31517
468bc8a1863d
debugtemplate: pass ui to templater so label() works
Yuya Nishihara <yuya@tcha.org>
parents:
31451
diff
changeset
|
2026 if not k or k == 'ui': |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2027 raise ValueError |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2028 props[k] = v |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2029 except ValueError: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2030 raise error.Abort(_('malformed keyword definition: %s') % d) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2031 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2032 if ui.verbose: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2033 aliases = ui.configitems('templatealias') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2034 tree = templater.parse(tmpl) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2035 ui.note(templater.prettyformat(tree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2036 newtree = templater.expandaliases(tree, aliases) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2037 if newtree != tree: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2038 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2039 |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2040 mapfile = None |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2041 if revs is None: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2042 k = 'debugtemplate' |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2043 t = formatter.maketemplater(ui, k, tmpl) |
31517
468bc8a1863d
debugtemplate: pass ui to templater so label() works
Yuya Nishihara <yuya@tcha.org>
parents:
31451
diff
changeset
|
2044 ui.write(templater.stringify(t(k, ui=ui, **props))) |
30957
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2045 else: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2046 displayer = cmdutil.changeset_templater(ui, repo, None, opts, tmpl, |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2047 mapfile, buffered=False) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2048 for r in revs: |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2049 displayer.show(repo[r], **props) |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2050 displayer.close() |
14794735faa8
debugcommands: move 'debugtemplate' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30956
diff
changeset
|
2051 |
30774
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2052 @command('debugupgraderepo', [ |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2053 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2054 ('', 'run', False, _('performs an upgrade')), |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2055 ]) |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2056 def debugupgraderepo(ui, repo, run=False, optimize=None): |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2057 """upgrade a repository to use different features |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2058 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2059 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
|
2060 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
|
2061 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2062 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
|
2063 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
|
2064 by the command output when run without ``--run``. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2065 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2066 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
|
2067 allowed. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2068 |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2069 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
|
2070 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
|
2071 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
|
2072 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
|
2073 unable to access the repository should be low. |
eaa5607132a2
debugcommands: stub for debugupgraderepo command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30743
diff
changeset
|
2074 """ |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30774
diff
changeset
|
2075 return repair.upgraderepo(ui, repo, run=run, optimize=optimize) |
30958
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2076 |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2077 @command('debugwalk', commands.walkopts, _('[OPTION]... [FILE]...'), |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2078 inferrepo=True) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2079 def debugwalk(ui, repo, *pats, **opts): |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2080 """show how files match on given patterns""" |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2081 m = scmutil.match(repo[None], pats, opts) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2082 items = list(repo.walk(m)) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2083 if not items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2084 return |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2085 f = lambda fn: fn |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2086 if ui.configbool('ui', 'slash') and pycompat.ossep != '/': |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2087 f = lambda fn: util.normpath(fn) |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2088 fmt = 'f %%-%ds %%-%ds %%s' % ( |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2089 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:
30957
diff
changeset
|
2090 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:
30957
diff
changeset
|
2091 for abs in items: |
df73368c87c3
debugcommands: move 'debugwalk' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30957
diff
changeset
|
2092 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:
30957
diff
changeset
|
2093 ui.write("%s\n" % line.rstrip()) |
30959
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2094 |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2095 @command('debugwireargs', |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2096 [('', 'three', '', 'three'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2097 ('', 'four', '', 'four'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2098 ('', 'five', '', 'five'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2099 ] + commands.remoteopts, |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2100 _('REPO [OPTIONS]... [ONE [TWO]]'), |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2101 norepo=True) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2102 def debugwireargs(ui, repopath, *vals, **opts): |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2103 repo = hg.peer(ui, opts, repopath) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2104 for opt in commands.remoteopts: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2105 del opts[opt[1]] |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2106 args = {} |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2107 for k, v in opts.iteritems(): |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2108 if v: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2109 args[k] = v |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2110 # run twice to check that we don't mess up the stream for the next command |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2111 res1 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2112 res2 = repo.debugwireargs(*vals, **args) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2113 ui.write("%s\n" % res1) |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2114 if res1 != res2: |
bd5694ce8beb
debugcommands: move 'debugwireargs' in the new module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30958
diff
changeset
|
2115 ui.warn("%s\n" % res2) |