Mercurial > hg
changeset 753:8760d0c83b9b
Check protocol versions
This also allows the old unidentified protocol
author | mpm@selenic.com |
---|---|
date | Thu, 21 Jul 2005 18:20:13 -0500 |
parents | c693eafd5967 |
children | 3e73bf876f17 |
files | mercurial/hg.py mercurial/hgweb.py |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Thu Jul 21 18:19:20 2005 -0500 +++ b/mercurial/hg.py Thu Jul 21 18:20:13 2005 -0500 @@ -1744,11 +1744,21 @@ qs = urllib.urlencode(q) cu = "%s?%s" % (self.url, qs) resp = urllib2.urlopen(cu) + proto = resp.headers['content-type'] - if not resp.headers['content-type'].startswith('application/hg'): + # accept old "text/plain" and "application/hg-changegroup" for now + if not proto.startswith('application/mercurial') and \ + not proto.startswith('text/plain') and \ + not proto.startswith('application/hg-changegroup'): raise RepoError("'%s' does not appear to be an hg repository" % self.url) + if proto.startswith('application/mercurial'): + version = proto[22:] + if float(version) > 0.1: + raise RepoError("'%s' uses newer protocol %s" % + (self.url, version)) + return resp def heads(self):
--- a/mercurial/hgweb.py Thu Jul 21 18:19:20 2005 -0500 +++ b/mercurial/hgweb.py Thu Jul 21 18:20:13 2005 -0500 @@ -670,7 +670,7 @@ sys.stdout.write(" ".join(map(hex, b)) + "\n") elif args['cmd'][0] == 'between': - httphdr("application/hg-0.1") + httphdr("application/mercurial-0.1") nodes = [] if args.has_key('pairs'): pairs = [ map(bin, p.split("-"))