sapling/eden/scm/tests/helpers-wireprotologging.sh
Xavier Deguillard 6f3af2ab10 tests: remove iteritems
Summary: The method doesn't exist in python3, let's simply replace it with items.

Reviewed By: quark-zju

Differential Revision: D19673674

fbshipit-source-id: b17eef7d820ae38db3fea1d457b0b8bb409f1b86
2020-01-31 17:31:23 -08:00

37 lines
1.0 KiB
Bash

capturewireprotologs() {
cat >> "$TESTTMP/uilog.py" <<EOF
from edenscm.mercurial import extensions
from edenscm.mercurial import ui as uimod
def uisetup(ui):
extensions.wrapfunction(uimod.ui, 'log', mylog)
def mylog(orig, self, service, *msg, **opts):
if service in ['wireproto_requests']:
kw = []
for k, v in sorted(opts.items()):
if k == 'args':
v = eval(v)
for arg in v:
if isinstance(arg, dict):
v = sorted(list(arg.items()))
v = str(v)
kw.append("%s=%s" % (k, v))
kwstr = ", ".join(kw)
msgstr = msg[0] % msg[1:]
self.warn('%s: %s (%s)\n' % (service, msgstr, kwstr))
with open('$TESTTMP/loggedrequests', 'a') as f:
f.write('%s: %s (%s)\n' % (service, msgstr, kwstr))
return orig(self, service, *msg, **opts)
EOF
cat >> "$HGRCPATH" <<EOF
[extensions]
uilog=$TESTTMP/uilog.py
[wireproto]
logrequests=batch,branchmap,getbundle,hello,listkeys,lookup,between,unbundle
loggetpack=True
EOF
}