##// END OF EJS Templates
Change User-agent field in client to have a lot more info.
Eric Hopper -
r6285:4b81eecc default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from node import bin, hex'
10 from remoterepo import remoterepository
10 from remoterepo import remoterepository
11 from i18n import _
11 from i18n import _
12 import repo, os, urllib, urllib2, urlparse, zlib, util, httplib
12 import repo, os, urllib, urllib2, urlparse, zlib, util, httplib
13 import errno, keepalive, socket, changegroup
13 import errno, keepalive, socket, changegroup, version
14
14
15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm):
15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm):
16 def __init__(self, ui):
16 def __init__(self, ui):
@@ -268,7 +268,7 b' class httprepository(remoterepository):'
268 opener = urllib2.build_opener(*handlers)
268 opener = urllib2.build_opener(*handlers)
269
269
270 # 1.0 here is the _protocol_ version
270 # 1.0 here is the _protocol_ version
271 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
271 opener.addheaders = [('User-agent', version.get_useragent())]
272 urllib2.install_opener(opener)
272 urllib2.install_opener(opener)
273
273
274 def url(self):
274 def url(self):
@@ -10,6 +10,8 b' Mercurial version'
10 """
10 """
11
11
12 import os
12 import os
13 import os.path
14 import sys
13 import re
15 import re
14 import time
16 import time
15
17
@@ -27,6 +29,16 b' def get_version(doreload=False):'
27 version = unknown_version
29 version = unknown_version
28 return version
30 return version
29
31
32 def get_useragent():
33 """Return some extended version information for the User-Agent
34 field in http requests."""
35 hgver = get_version()
36 pyver = '%s(%s)' % (sys.version.split()[0], hex(sys.hexversion))
37 ostype = os.name
38 plat = sys.platform
39 return 'mercurial/proto-1.0 (Python/%s; Mercurial/%s; %s/%s)' % \
40 (pyver, hgver, ostype, plat)
41
30 def write_version(version):
42 def write_version(version):
31 """Overwrite version file."""
43 """Overwrite version file."""
32 if version == get_version():
44 if version == get_version():
General Comments 0
You need to be logged in to leave comments. Login now