##// END OF EJS Templates
When pulling from a non hg repository URL (e.g. http://www.kernel.org/hg)...
Muli Ben-Yehuda -
r751:0b245ede default
parent child Browse files
Show More
@@ -1753,10 +1753,20 b' class httprepository:'
1753 self.ui.warn("unexpected response:\n" + d[:400] + "\n...\n")
1753 self.ui.warn("unexpected response:\n" + d[:400] + "\n...\n")
1754 raise
1754 raise
1755
1755
1756 def verify_hg_repo(self, resp):
1757 if (resp.headers['content-type'] == 'application/hg-0.1'):
1758 pass
1759 else:
1760 msg = """'%s' does not appear to be a valid hg repository -
1761 missing a 'Content-type: application/hg-0.1' HTTP header""" % (self.url,)
1762 raise RepoError(msg)
1763
1756 def branches(self, nodes):
1764 def branches(self, nodes):
1757 n = " ".join(map(hex, nodes))
1765 n = " ".join(map(hex, nodes))
1758 d = self.do_cmd("branches", nodes=n).read()
1766 resp = self.do_cmd("branches", nodes=n);
1767 self.verify_hg_repo(resp);
1759 try:
1768 try:
1769 d = resp.read()
1760 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ]
1770 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ]
1761 return br
1771 return br
1762 except:
1772 except:
@@ -1765,8 +1775,10 b' class httprepository:'
1765
1775
1766 def between(self, pairs):
1776 def between(self, pairs):
1767 n = "\n".join(["-".join(map(hex, p)) for p in pairs])
1777 n = "\n".join(["-".join(map(hex, p)) for p in pairs])
1768 d = self.do_cmd("between", pairs=n).read()
1778 resp = self.do_cmd("between", pairs=n)
1779 self.verify_hg_repo(resp)
1769 try:
1780 try:
1781 d = resp.read()
1770 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
1782 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
1771 return p
1783 return p
1772 except:
1784 except:
@@ -1775,7 +1787,8 b' class httprepository:'
1775
1787
1776 def changegroup(self, nodes):
1788 def changegroup(self, nodes):
1777 n = " ".join(map(hex, nodes))
1789 n = " ".join(map(hex, nodes))
1778 f = self.do_cmd("changegroup", roots=n)
1790 resp = self.do_cmd("changegroup", roots=n)
1791 self.verify_hg_repo(resp)
1779 bytes = 0
1792 bytes = 0
1780
1793
1781 class zread:
1794 class zread:
@@ -1785,7 +1798,7 b' class httprepository:'
1785 self.buf = ""
1798 self.buf = ""
1786 def read(self, l):
1799 def read(self, l):
1787 while l > len(self.buf):
1800 while l > len(self.buf):
1788 r = f.read(4096)
1801 r = self.f.read(4096)
1789 if r:
1802 if r:
1790 self.buf += self.zd.decompress(r)
1803 self.buf += self.zd.decompress(r)
1791 else:
1804 else:
@@ -1794,7 +1807,7 b' class httprepository:'
1794 d, self.buf = self.buf[:l], self.buf[l:]
1807 d, self.buf = self.buf[:l], self.buf[l:]
1795 return d
1808 return d
1796
1809
1797 return zread(f)
1810 return zread(resp)
1798
1811
1799 class remotelock:
1812 class remotelock:
1800 def __init__(self, repo):
1813 def __init__(self, repo):
@@ -657,12 +657,12 b' class hgweb:'
657 write(self.filelog(args['file'][0], args['filenode'][0]))
657 write(self.filelog(args['file'][0], args['filenode'][0]))
658
658
659 elif args['cmd'][0] == 'heads':
659 elif args['cmd'][0] == 'heads':
660 httphdr("text/plain")
660 httphdr("application/mercurial-0.1")
661 h = self.repo.heads()
661 h = self.repo.heads()
662 sys.stdout.write(" ".join(map(hex, h)) + "\n")
662 sys.stdout.write(" ".join(map(hex, h)) + "\n")
663
663
664 elif args['cmd'][0] == 'branches':
664 elif args['cmd'][0] == 'branches':
665 httphdr("text/plain")
665 httphdr("application/mercurial-0.1")
666 nodes = []
666 nodes = []
667 if args.has_key('nodes'):
667 if args.has_key('nodes'):
668 nodes = map(bin, args['nodes'][0].split(" "))
668 nodes = map(bin, args['nodes'][0].split(" "))
@@ -670,7 +670,7 b' class hgweb:'
670 sys.stdout.write(" ".join(map(hex, b)) + "\n")
670 sys.stdout.write(" ".join(map(hex, b)) + "\n")
671
671
672 elif args['cmd'][0] == 'between':
672 elif args['cmd'][0] == 'between':
673 httphdr("text/plain")
673 httphdr("application/hg-0.1")
674 nodes = []
674 nodes = []
675 if args.has_key('pairs'):
675 if args.has_key('pairs'):
676 pairs = [ map(bin, p.split("-"))
676 pairs = [ map(bin, p.split("-"))
@@ -679,7 +679,7 b' class hgweb:'
679 sys.stdout.write(" ".join(map(hex, b)) + "\n")
679 sys.stdout.write(" ".join(map(hex, b)) + "\n")
680
680
681 elif args['cmd'][0] == 'changegroup':
681 elif args['cmd'][0] == 'changegroup':
682 httphdr("application/hg-changegroup")
682 httphdr("application/mercurial-0.1")
683 nodes = []
683 nodes = []
684 if self.viewonly:
684 if self.viewonly:
685 return
685 return
General Comments 0
You need to be logged in to leave comments. Login now