Mercurial > hg
annotate contrib/debugcmdserver.py @ 44382:f0027a3dd7cb
revlog-compression: update the config to be a list
format.revlog-compression is now a list of engine, the first supported one is to
be used. Doing this have several benefits:
1) this is fully backward compatible, config using a single entry will be read
as a single item list, not changing any behavior.
2) This open the way to use zstd by default without impacting platform were it
is not available. This will be done in a later changesets.
Using zstd provide a significant performance boost explained in : bb271ec2fbfb.
However zstd is not available in some cases, A notable example is the `--pure`
version of Mercurial which doesn't come with zstd support.
Differential Revision: https://phab.mercurial-scm.org/D8148
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 19 Feb 2020 17:30:04 +0100 |
parents | 2372284d9457 |
children | c102b704edb5 |
rev | line source |
---|---|
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 # |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 # Dumps output generated by Mercurial's command server in a formatted style to a |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 # given file or stderr if '-' is specified. Output is also written in its raw |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 # format to stdout. |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 # |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 # $ ./hg serve --cmds pipe | ./contrib/debugcmdserver.py - |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 # o, 52 -> 'capabilities: getencoding runcommand\nencoding: UTF-8' |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 |
28353
cd03fbd5ab57
debugcmdserver: use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
16687
diff
changeset
|
10 from __future__ import absolute_import, print_function |
cd03fbd5ab57
debugcmdserver: use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
16687
diff
changeset
|
11 import struct |
cd03fbd5ab57
debugcmdserver: use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
16687
diff
changeset
|
12 import sys |
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 if len(sys.argv) != 2: |
28353
cd03fbd5ab57
debugcmdserver: use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
16687
diff
changeset
|
15 print('usage: debugcmdserver.py FILE') |
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 sys.exit(1) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 outputfmt = '>cI' |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
19 outputfmtsize = struct.calcsize(outputfmt) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
20 |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
21 if sys.argv[1] == '-': |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
22 log = sys.stderr |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
23 else: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
24 log = open(sys.argv[1], 'a') |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
25 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28353
diff
changeset
|
26 |
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
27 def read(size): |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
28 data = sys.stdin.read(size) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
29 if not data: |
16687
e34106fa0dc3
cleanup: "raise SomeException()" -> "raise SomeException"
Brodie Rao <brodie@sf.io>
parents:
15259
diff
changeset
|
30 raise EOFError |
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
31 sys.stdout.write(data) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
32 sys.stdout.flush() |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
33 return data |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
34 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
28353
diff
changeset
|
35 |
15259
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
36 try: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
37 while True: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
38 header = read(outputfmtsize) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
39 channel, length = struct.unpack(outputfmt, header) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
40 log.write('%s, %-4d' % (channel, length)) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
41 if channel in 'IL': |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
42 log.write(' -> waiting for input\n') |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
43 else: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
44 data = read(length) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
45 log.write(' -> %r\n' % data) |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
46 log.flush() |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
47 except EOFError: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
48 pass |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
49 finally: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
50 if log != sys.stderr: |
1d1f6dff9364
contrib: add a script to help diagnose raw output of the cmdserver
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
51 log.close() |