Mercurial > hg
changeset 6285:4b81eecc8aa2
Change User-agent field in client to have a lot more info.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Sat, 15 Mar 2008 12:42:41 -0700 |
parents | c93b6c0e6e84 |
children | 90a4329a6b4a 91ac1726730a 9c195637ac0b |
files | mercurial/httprepo.py mercurial/version.py |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/httprepo.py Sat Mar 15 12:42:34 2008 -0700 +++ b/mercurial/httprepo.py Sat Mar 15 12:42:41 2008 -0700 @@ -10,7 +10,7 @@ from remoterepo import remoterepository from i18n import _ import repo, os, urllib, urllib2, urlparse, zlib, util, httplib -import errno, keepalive, socket, changegroup +import errno, keepalive, socket, changegroup, version class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): def __init__(self, ui): @@ -268,7 +268,7 @@ opener = urllib2.build_opener(*handlers) # 1.0 here is the _protocol_ version - opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] + opener.addheaders = [('User-agent', version.get_useragent())] urllib2.install_opener(opener) def url(self):
--- a/mercurial/version.py Sat Mar 15 12:42:34 2008 -0700 +++ b/mercurial/version.py Sat Mar 15 12:42:41 2008 -0700 @@ -10,6 +10,8 @@ """ import os +import os.path +import sys import re import time @@ -27,6 +29,16 @@ version = unknown_version return version +def get_useragent(): + """Return some extended version information for the User-Agent + field in http requests.""" + hgver = get_version() + pyver = '%s(%s)' % (sys.version.split()[0], hex(sys.hexversion)) + ostype = os.name + plat = sys.platform + return 'mercurial/proto-1.0 (Python/%s; Mercurial/%s; %s/%s)' % \ + (pyver, hgver, ostype, plat) + def write_version(version): """Overwrite version file.""" if version == get_version():