comparison mercurial/hg.py @ 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 eea96285cbf9
comparison
equal deleted inserted replaced
752:c693eafd5967 753:8760d0c83b9b
1742 q = {"cmd": cmd} 1742 q = {"cmd": cmd}
1743 q.update(args) 1743 q.update(args)
1744 qs = urllib.urlencode(q) 1744 qs = urllib.urlencode(q)
1745 cu = "%s?%s" % (self.url, qs) 1745 cu = "%s?%s" % (self.url, qs)
1746 resp = urllib2.urlopen(cu) 1746 resp = urllib2.urlopen(cu)
1747 1747 proto = resp.headers['content-type']
1748 if not resp.headers['content-type'].startswith('application/hg'): 1748
1749 # accept old "text/plain" and "application/hg-changegroup" for now
1750 if not proto.startswith('application/mercurial') and \
1751 not proto.startswith('text/plain') and \
1752 not proto.startswith('application/hg-changegroup'):
1749 raise RepoError("'%s' does not appear to be an hg repository" 1753 raise RepoError("'%s' does not appear to be an hg repository"
1750 % self.url) 1754 % self.url)
1755
1756 if proto.startswith('application/mercurial'):
1757 version = proto[22:]
1758 if float(version) > 0.1:
1759 raise RepoError("'%s' uses newer protocol %s" %
1760 (self.url, version))
1751 1761
1752 return resp 1762 return resp
1753 1763
1754 def heads(self): 1764 def heads(self):
1755 d = self.do_cmd("heads").read() 1765 d = self.do_cmd("heads").read()