##// 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 1753 self.ui.warn("unexpected response:\n" + d[:400] + "\n...\n")
1754 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 1764 def branches(self, nodes):
1757 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 1768 try:
1769 d = resp.read()
1760 1770 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ]
1761 1771 return br
1762 1772 except:
@@ -1765,8 +1775,10 b' class httprepository:'
1765 1775
1766 1776 def between(self, pairs):
1767 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 1780 try:
1781 d = resp.read()
1770 1782 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
1771 1783 return p
1772 1784 except:
@@ -1775,7 +1787,8 b' class httprepository:'
1775 1787
1776 1788 def changegroup(self, nodes):
1777 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 1792 bytes = 0
1780 1793
1781 1794 class zread:
@@ -1785,7 +1798,7 b' class httprepository:'
1785 1798 self.buf = ""
1786 1799 def read(self, l):
1787 1800 while l > len(self.buf):
1788 r = f.read(4096)
1801 r = self.f.read(4096)
1789 1802 if r:
1790 1803 self.buf += self.zd.decompress(r)
1791 1804 else:
@@ -1794,7 +1807,7 b' class httprepository:'
1794 1807 d, self.buf = self.buf[:l], self.buf[l:]
1795 1808 return d
1796 1809
1797 return zread(f)
1810 return zread(resp)
1798 1811
1799 1812 class remotelock:
1800 1813 def __init__(self, repo):
@@ -657,12 +657,12 b' class hgweb:'
657 657 write(self.filelog(args['file'][0], args['filenode'][0]))
658 658
659 659 elif args['cmd'][0] == 'heads':
660 httphdr("text/plain")
660 httphdr("application/mercurial-0.1")
661 661 h = self.repo.heads()
662 662 sys.stdout.write(" ".join(map(hex, h)) + "\n")
663 663
664 664 elif args['cmd'][0] == 'branches':
665 httphdr("text/plain")
665 httphdr("application/mercurial-0.1")
666 666 nodes = []
667 667 if args.has_key('nodes'):
668 668 nodes = map(bin, args['nodes'][0].split(" "))
@@ -670,7 +670,7 b' class hgweb:'
670 670 sys.stdout.write(" ".join(map(hex, b)) + "\n")
671 671
672 672 elif args['cmd'][0] == 'between':
673 httphdr("text/plain")
673 httphdr("application/hg-0.1")
674 674 nodes = []
675 675 if args.has_key('pairs'):
676 676 pairs = [ map(bin, p.split("-"))
@@ -679,7 +679,7 b' class hgweb:'
679 679 sys.stdout.write(" ".join(map(hex, b)) + "\n")
680 680
681 681 elif args['cmd'][0] == 'changegroup':
682 httphdr("application/hg-changegroup")
682 httphdr("application/mercurial-0.1")
683 683 nodes = []
684 684 if self.viewonly:
685 685 return
General Comments 0
You need to be logged in to leave comments. Login now