Mercurial > public > mercurial-scm > hg
comparison mercurial/keepalive.py @ 46113:59fa3890d40a
node: import symbols explicitly
There is no point in lazy importing mercurial.node, it is used all over
the place anyway. So consistently import the used symbols directly.
Fix one file using symbols indirectly via mercurial.revlog.
Differential Revision: https://phab.mercurial-scm.org/D9480
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 01 Dec 2020 21:54:46 +0100 |
parents | 89a2afe31e82 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
46112:d6afa9c149c3 | 46113:59fa3890d40a |
---|---|
91 import sys | 91 import sys |
92 import threading | 92 import threading |
93 | 93 |
94 from .i18n import _ | 94 from .i18n import _ |
95 from .pycompat import getattr | 95 from .pycompat import getattr |
96 from .node import hex | |
96 from . import ( | 97 from . import ( |
97 node, | |
98 pycompat, | 98 pycompat, |
99 urllibcompat, | 99 urllibcompat, |
100 util, | 100 util, |
101 ) | 101 ) |
102 from .utils import procutil | 102 from .utils import procutil |
721 urlreq.installopener(opener) | 721 urlreq.installopener(opener) |
722 fo = urlreq.urlopen(url) | 722 fo = urlreq.urlopen(url) |
723 foo = fo.read() | 723 foo = fo.read() |
724 fo.close() | 724 fo.close() |
725 m = md5(foo) | 725 m = md5(foo) |
726 print(format % (b'normal urllib', node.hex(m.digest()))) | 726 print(format % (b'normal urllib', hex(m.digest()))) |
727 | 727 |
728 # now install the keepalive handler and try again | 728 # now install the keepalive handler and try again |
729 opener = urlreq.buildopener(HTTPHandler()) | 729 opener = urlreq.buildopener(HTTPHandler()) |
730 urlreq.installopener(opener) | 730 urlreq.installopener(opener) |
731 | 731 |
732 fo = urlreq.urlopen(url) | 732 fo = urlreq.urlopen(url) |
733 foo = fo.read() | 733 foo = fo.read() |
734 fo.close() | 734 fo.close() |
735 m = md5(foo) | 735 m = md5(foo) |
736 print(format % (b'keepalive read', node.hex(m.digest()))) | 736 print(format % (b'keepalive read', hex(m.digest()))) |
737 | 737 |
738 fo = urlreq.urlopen(url) | 738 fo = urlreq.urlopen(url) |
739 foo = b'' | 739 foo = b'' |
740 while True: | 740 while True: |
741 f = fo.readline() | 741 f = fo.readline() |
743 foo = foo + f | 743 foo = foo + f |
744 else: | 744 else: |
745 break | 745 break |
746 fo.close() | 746 fo.close() |
747 m = md5(foo) | 747 m = md5(foo) |
748 print(format % (b'keepalive readline', node.hex(m.digest()))) | 748 print(format % (b'keepalive readline', hex(m.digest()))) |
749 | 749 |
750 | 750 |
751 def comp(N, url): | 751 def comp(N, url): |
752 print(b' making %i connections to:\n %s' % (N, url)) | 752 print(b' making %i connections to:\n %s' % (N, url)) |
753 | 753 |