Show More
@@ -2839,9 +2839,13 b' def debugwireproto(ui, repo, path=None, ' | |||
|
2839 | 2839 | r'loggingname': b's', |
|
2840 | 2840 | r'loggingopts': { |
|
2841 | 2841 | r'logdata': True, |
|
2842 | r'logdataapis': False, | |
|
2842 | 2843 | }, |
|
2843 | 2844 | } |
|
2844 | 2845 | |
|
2846 | if ui.debugflag: | |
|
2847 | openerargs[r'loggingopts'][r'logdataapis'] = True | |
|
2848 | ||
|
2845 | 2849 | opener = urlmod.opener(ui, authinfo, **openerargs) |
|
2846 | 2850 | |
|
2847 | 2851 | if opts['peer'] == 'raw': |
@@ -762,7 +762,8 b' class socketproxy(object):' | |||
|
762 | 762 | return makeloggingfileobject(observer.fh, res, observer.name, |
|
763 | 763 | reads=observer.reads, |
|
764 | 764 | writes=observer.writes, |
|
765 |
logdata=observer.logdata |
|
|
765 | logdata=observer.logdata, | |
|
766 | logdataapis=observer.logdataapis) | |
|
766 | 767 | |
|
767 | 768 | def recv(self, *args, **kwargs): |
|
768 | 769 | return object.__getattribute__(self, r'_observedcall')( |
@@ -825,18 +826,24 b' def escapedata(s):' | |||
|
825 | 826 | class baseproxyobserver(object): |
|
826 | 827 | def _writedata(self, data): |
|
827 | 828 | if not self.logdata: |
|
829 | if self.logdataapis: | |
|
828 | 830 | self.fh.write('\n') |
|
829 | 831 | self.fh.flush() |
|
830 | 832 | return |
|
831 | 833 | |
|
832 | 834 | # Simple case writes all data on a single line. |
|
833 | 835 | if b'\n' not in data: |
|
836 | if self.logdataapis: | |
|
834 | 837 | self.fh.write(': %s\n' % escapedata(data)) |
|
838 | else: | |
|
839 | self.fh.write('%s> %s\n' % (self.name, escapedata(data))) | |
|
835 | 840 | self.fh.flush() |
|
836 | 841 | return |
|
837 | 842 | |
|
838 | 843 | # Data with newlines is written to multiple lines. |
|
844 | if self.logdataapis: | |
|
839 | 845 | self.fh.write(':\n') |
|
846 | ||
|
840 | 847 | lines = data.splitlines(True) |
|
841 | 848 | for line in lines: |
|
842 | 849 | self.fh.write('%s> %s\n' % (self.name, escapedata(line))) |
@@ -844,10 +851,12 b' class baseproxyobserver(object):' | |||
|
844 | 851 | |
|
845 | 852 | class fileobjectobserver(baseproxyobserver): |
|
846 | 853 | """Logs file object activity.""" |
|
847 |
def __init__(self, fh, name, reads=True, writes=True, logdata=False |
|
|
854 | def __init__(self, fh, name, reads=True, writes=True, logdata=False, | |
|
855 | logdataapis=True): | |
|
848 | 856 | self.fh = fh |
|
849 | 857 | self.name = name |
|
850 | 858 | self.logdata = logdata |
|
859 | self.logdataapis = logdataapis | |
|
851 | 860 | self.reads = reads |
|
852 | 861 | self.writes = writes |
|
853 | 862 | |
@@ -858,22 +867,28 b' class fileobjectobserver(baseproxyobserv' | |||
|
858 | 867 | if res is None: |
|
859 | 868 | res = '' |
|
860 | 869 | |
|
870 | if self.logdataapis: | |
|
861 | 871 | self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res))) |
|
872 | ||
|
862 | 873 | self._writedata(res) |
|
863 | 874 | |
|
864 | 875 | def readline(self, res, limit=-1): |
|
865 | 876 | if not self.reads: |
|
866 | 877 | return |
|
867 | 878 | |
|
879 | if self.logdataapis: | |
|
868 | 880 | self.fh.write('%s> readline() -> %d' % (self.name, len(res))) |
|
881 | ||
|
869 | 882 | self._writedata(res) |
|
870 | 883 | |
|
871 | 884 | def readinto(self, res, dest): |
|
872 | 885 | if not self.reads: |
|
873 | 886 | return |
|
874 | 887 | |
|
888 | if self.logdataapis: | |
|
875 | 889 | self.fh.write('%s> readinto(%d) -> %r' % (self.name, len(dest), |
|
876 | 890 | res)) |
|
891 | ||
|
877 | 892 | data = dest[0:res] if res is not None else b'' |
|
878 | 893 | self._writedata(data) |
|
879 | 894 | |
@@ -886,7 +901,9 b' class fileobjectobserver(baseproxyobserv' | |||
|
886 | 901 | if res is None and data: |
|
887 | 902 | res = len(data) |
|
888 | 903 | |
|
904 | if self.logdataapis: | |
|
889 | 905 | self.fh.write('%s> write(%d) -> %r' % (self.name, len(data), res)) |
|
906 | ||
|
890 | 907 | self._writedata(data) |
|
891 | 908 | |
|
892 | 909 | def flush(self, res): |
@@ -897,32 +914,44 b' class fileobjectobserver(baseproxyobserv' | |||
|
897 | 914 | |
|
898 | 915 | # For observedbufferedinputpipe. |
|
899 | 916 | def bufferedread(self, res, size): |
|
917 | if not self.reads: | |
|
918 | return | |
|
919 | ||
|
920 | if self.logdataapis: | |
|
900 | 921 | self.fh.write('%s> bufferedread(%d) -> %d' % ( |
|
901 | 922 | self.name, size, len(res))) |
|
923 | ||
|
902 | 924 | self._writedata(res) |
|
903 | 925 | |
|
904 | 926 | def bufferedreadline(self, res): |
|
905 | self.fh.write('%s> bufferedreadline() -> %d' % (self.name, len(res))) | |
|
927 | if not self.reads: | |
|
928 | return | |
|
929 | ||
|
930 | if self.logdataapis: | |
|
931 | self.fh.write('%s> bufferedreadline() -> %d' % ( | |
|
932 | self.name, len(res))) | |
|
933 | ||
|
906 | 934 | self._writedata(res) |
|
907 | 935 | |
|
908 | 936 | def makeloggingfileobject(logh, fh, name, reads=True, writes=True, |
|
909 | logdata=False): | |
|
937 | logdata=False, logdataapis=True): | |
|
910 | 938 | """Turn a file object into a logging file object.""" |
|
911 | 939 | |
|
912 | 940 | observer = fileobjectobserver(logh, name, reads=reads, writes=writes, |
|
913 | logdata=logdata) | |
|
941 | logdata=logdata, logdataapis=logdataapis) | |
|
914 | 942 | return fileobjectproxy(fh, observer) |
|
915 | 943 | |
|
916 | 944 | class socketobserver(baseproxyobserver): |
|
917 | 945 | """Logs socket activity.""" |
|
918 | 946 | def __init__(self, fh, name, reads=True, writes=True, states=True, |
|
919 | logdata=False): | |
|
947 | logdata=False, logdataapis=True): | |
|
920 | 948 | self.fh = fh |
|
921 | 949 | self.name = name |
|
922 | 950 | self.reads = reads |
|
923 | 951 | self.writes = writes |
|
924 | 952 | self.states = states |
|
925 | 953 | self.logdata = logdata |
|
954 | self.logdataapis = logdataapis | |
|
926 | 955 | |
|
927 | 956 | def makefile(self, res, mode=None, bufsize=None): |
|
928 | 957 | if not self.states: |
@@ -935,6 +964,7 b' class socketobserver(baseproxyobserver):' | |||
|
935 | 964 | if not self.reads: |
|
936 | 965 | return |
|
937 | 966 | |
|
967 | if self.logdataapis: | |
|
938 | 968 | self.fh.write('%s> recv(%d, %d) -> %d' % ( |
|
939 | 969 | self.name, size, flags, len(res))) |
|
940 | 970 | self._writedata(res) |
@@ -943,24 +973,30 b' class socketobserver(baseproxyobserver):' | |||
|
943 | 973 | if not self.reads: |
|
944 | 974 | return |
|
945 | 975 | |
|
976 | if self.logdataapis: | |
|
946 | 977 | self.fh.write('%s> recvfrom(%d, %d) -> %d' % ( |
|
947 | 978 | self.name, size, flags, len(res[0]))) |
|
979 | ||
|
948 | 980 | self._writedata(res[0]) |
|
949 | 981 | |
|
950 | 982 | def recvfrom_into(self, res, buf, size, flags=0): |
|
951 | 983 | if not self.reads: |
|
952 | 984 | return |
|
953 | 985 | |
|
986 | if self.logdataapis: | |
|
954 | 987 | self.fh.write('%s> recvfrom_into(%d, %d) -> %d' % ( |
|
955 | 988 | self.name, size, flags, res[0])) |
|
989 | ||
|
956 | 990 | self._writedata(buf[0:res[0]]) |
|
957 | 991 | |
|
958 | 992 | def recv_into(self, res, buf, size=0, flags=0): |
|
959 | 993 | if not self.reads: |
|
960 | 994 | return |
|
961 | 995 | |
|
996 | if self.logdataapis: | |
|
962 | 997 | self.fh.write('%s> recv_into(%d, %d) -> %d' % ( |
|
963 | 998 | self.name, size, flags, res)) |
|
999 | ||
|
964 | 1000 | self._writedata(buf[0:res]) |
|
965 | 1001 | |
|
966 | 1002 | def send(self, res, data, flags=0): |
@@ -975,9 +1011,11 b' class socketobserver(baseproxyobserver):' | |||
|
975 | 1011 | if not self.writes: |
|
976 | 1012 | return |
|
977 | 1013 | |
|
1014 | if self.logdataapis: | |
|
978 | 1015 | # Returns None on success. So don't bother reporting return value. |
|
979 | 1016 | self.fh.write('%s> sendall(%d, %d)' % ( |
|
980 | 1017 | self.name, len(data), flags)) |
|
1018 | ||
|
981 | 1019 | self._writedata(data) |
|
982 | 1020 | |
|
983 | 1021 | def sendto(self, res, data, flagsoraddress, address=None): |
@@ -989,8 +1027,10 b' class socketobserver(baseproxyobserver):' | |||
|
989 | 1027 | else: |
|
990 | 1028 | flags = 0 |
|
991 | 1029 | |
|
1030 | if self.logdataapis: | |
|
992 | 1031 | self.fh.write('%s> sendto(%d, %d, %r) -> %d' % ( |
|
993 | 1032 | self.name, len(data), flags, address, res)) |
|
1033 | ||
|
994 | 1034 | self._writedata(data) |
|
995 | 1035 | |
|
996 | 1036 | def setblocking(self, res, flag): |
@@ -1019,11 +1059,12 b' class socketobserver(baseproxyobserver):' | |||
|
1019 | 1059 | self.name, level, optname, value)) |
|
1020 | 1060 | |
|
1021 | 1061 | def makeloggingsocket(logh, fh, name, reads=True, writes=True, states=True, |
|
1022 | logdata=False): | |
|
1062 | logdata=False, logdataapis=True): | |
|
1023 | 1063 | """Turn a socket into a logging socket.""" |
|
1024 | 1064 | |
|
1025 | 1065 | observer = socketobserver(logh, name, reads=reads, writes=writes, |
|
1026 |
states=states, logdata=logdata |
|
|
1066 | states=states, logdata=logdata, | |
|
1067 | logdataapis=logdataapis) | |
|
1027 | 1068 | return socketproxy(fh, observer) |
|
1028 | 1069 | |
|
1029 | 1070 | def version(): |
@@ -175,7 +175,6 b' Test listkeys for listing namespaces' | |||
|
175 | 175 | > command listkeys |
|
176 | 176 | > namespace namespaces |
|
177 | 177 | > EOF |
|
178 | s> sendall(*, 0): (glob) | |
|
179 | 178 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
180 | 179 | s> Accept-Encoding: identity\r\n |
|
181 | 180 | s> accept: application/mercurial-0.1\r\n |
@@ -183,21 +182,14 b' Test listkeys for listing namespaces' | |||
|
183 | 182 | s> user-agent: mercurial/proto-1.0 (Mercurial *)\r\n (glob) |
|
184 | 183 | s> \r\n |
|
185 | 184 | s> makefile('rb', None) |
|
186 | s> readline() -> 36: | |
|
187 | 185 | s> HTTP/1.1 200 Script output follows\r\n |
|
188 | s> readline() -> 28: | |
|
189 | 186 | s> Server: testing stub value\r\n |
|
190 | s> readline() -> *: (glob) | |
|
191 | 187 | s> Date: $HTTP_DATE$\r\n |
|
192 | s> readline() -> 41: | |
|
193 | 188 | s> Content-Type: application/mercurial-0.1\r\n |
|
194 | s> readline() -> 21: | |
|
195 | 189 | s> Content-Length: *\r\n (glob) |
|
196 | s> readline() -> 2: | |
|
197 | 190 | s> \r\n |
|
198 |
s> |
|
|
191 | s> lookup branchmap pushkey known getbundle unbundlehash batch changegroupsubset streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=$BUNDLE2_COMPRESSIONS$ | |
|
199 | 192 | sending listkeys command |
|
200 | s> sendall(*, 0): (glob) | |
|
201 | 193 | s> GET /?cmd=listkeys HTTP/1.1\r\n |
|
202 | 194 | s> Accept-Encoding: identity\r\n |
|
203 | 195 | s> vary: X-HgArg-1,X-HgProto-1\r\n |
@@ -208,19 +200,12 b' Test listkeys for listing namespaces' | |||
|
208 | 200 | s> user-agent: mercurial/proto-1.0 (Mercurial *)\r\n (glob) |
|
209 | 201 | s> \r\n |
|
210 | 202 | s> makefile('rb', None) |
|
211 | s> readline() -> 36: | |
|
212 | 203 | s> HTTP/1.1 200 Script output follows\r\n |
|
213 | s> readline() -> 28: | |
|
214 | 204 | s> Server: testing stub value\r\n |
|
215 | s> readline() -> *: (glob) | |
|
216 | 205 | s> Date: $HTTP_DATE$\r\n |
|
217 | s> readline() -> 41: | |
|
218 | 206 | s> Content-Type: application/mercurial-0.1\r\n |
|
219 | s> readline() -> 20: | |
|
220 | 207 | s> Content-Length: 30\r\n |
|
221 | s> readline() -> 2: | |
|
222 | 208 | s> \r\n |
|
223 | s> read(30) -> 30: | |
|
224 | 209 | s> bookmarks \n |
|
225 | 210 | s> namespaces \n |
|
226 | 211 | s> phases |
@@ -235,7 +220,6 b' Same thing, but with "httprequest" comma' | |||
|
235 | 220 | > x-hgarg-1: namespace=namespaces |
|
236 | 221 | > EOF |
|
237 | 222 | using raw connection to peer |
|
238 | s> sendall(*, 0): (glob) | |
|
239 | 223 | s> GET /?cmd=listkeys HTTP/1.1\r\n |
|
240 | 224 | s> Accept-Encoding: identity\r\n |
|
241 | 225 | s> accept: application/mercurial-0.1\r\n |
@@ -244,19 +228,12 b' Same thing, but with "httprequest" comma' | |||
|
244 | 228 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
245 | 229 | s> \r\n |
|
246 | 230 | s> makefile('rb', None) |
|
247 | s> readline() -> 36: | |
|
248 | 231 | s> HTTP/1.1 200 Script output follows\r\n |
|
249 | s> readline() -> 28: | |
|
250 | 232 | s> Server: testing stub value\r\n |
|
251 | s> readline() -> *: (glob) | |
|
252 | 233 | s> Date: $HTTP_DATE$\r\n |
|
253 | s> readline() -> 41: | |
|
254 | 234 | s> Content-Type: application/mercurial-0.1\r\n |
|
255 | s> readline() -> 20: | |
|
256 | 235 | s> Content-Length: 30\r\n |
|
257 | s> readline() -> 2: | |
|
258 | 236 | s> \r\n |
|
259 | s> read(30) -> 30: | |
|
260 | 237 | s> bookmarks \n |
|
261 | 238 | s> namespaces \n |
|
262 | 239 | s> phases |
General Comments 0
You need to be logged in to leave comments.
Login now