8 |
8 |
9 import os |
9 import os |
10 import os.path |
10 import os.path |
11 import mimetypes |
11 import mimetypes |
12 from mercurial.demandload import demandload |
12 from mercurial.demandload import demandload |
13 demandload(globals(), "re zlib ConfigParser") |
13 demandload(globals(), "re zlib ConfigParser cStringIO") |
14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater") |
14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater") |
15 demandload(globals(), "mercurial.hgweb.request:hgrequest") |
15 demandload(globals(), "mercurial.hgweb.request:hgrequest") |
16 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") |
16 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") |
17 from mercurial.node import * |
17 from mercurial.node import * |
18 from mercurial.i18n import gettext as _ |
18 from mercurial.i18n import gettext as _ |
759 elif cmd == 'filelog': |
759 elif cmd == 'filelog': |
760 req.write(self.filelog(clean(req.form['file'][0]), |
760 req.write(self.filelog(clean(req.form['file'][0]), |
761 req.form['filenode'][0])) |
761 req.form['filenode'][0])) |
762 |
762 |
763 elif cmd == 'heads': |
763 elif cmd == 'heads': |
764 req.httphdr("application/mercurial-0.1") |
764 resp = " ".join(map(hex, self.repo.heads())) + "\n" |
765 h = self.repo.heads() |
765 req.httphdr("application/mercurial-0.1", length=len(resp)) |
766 req.write(" ".join(map(hex, h)) + "\n") |
766 req.write(resp) |
767 |
767 |
768 elif cmd == 'branches': |
768 elif cmd == 'branches': |
769 req.httphdr("application/mercurial-0.1") |
|
770 nodes = [] |
769 nodes = [] |
771 if req.form.has_key('nodes'): |
770 if req.form.has_key('nodes'): |
772 nodes = map(bin, req.form['nodes'][0].split(" ")) |
771 nodes = map(bin, req.form['nodes'][0].split(" ")) |
|
772 resp = cStringIO.StringIO() |
773 for b in self.repo.branches(nodes): |
773 for b in self.repo.branches(nodes): |
774 req.write(" ".join(map(hex, b)) + "\n") |
774 resp.write(" ".join(map(hex, b)) + "\n") |
|
775 resp = resp.getvalue() |
|
776 req.httphdr("application/mercurial-0.1", length=len(resp)) |
|
777 req.write(resp) |
775 |
778 |
776 elif cmd == 'between': |
779 elif cmd == 'between': |
777 req.httphdr("application/mercurial-0.1") |
|
778 nodes = [] |
780 nodes = [] |
779 if req.form.has_key('pairs'): |
781 if req.form.has_key('pairs'): |
780 pairs = [map(bin, p.split("-")) |
782 pairs = [map(bin, p.split("-")) |
781 for p in req.form['pairs'][0].split(" ")] |
783 for p in req.form['pairs'][0].split(" ")] |
|
784 resp = cStringIO.StringIO() |
782 for b in self.repo.between(pairs): |
785 for b in self.repo.between(pairs): |
783 req.write(" ".join(map(hex, b)) + "\n") |
786 resp.write(" ".join(map(hex, b)) + "\n") |
|
787 resp = resp.getvalue() |
|
788 req.httphdr("application/mercurial-0.1", length=len(resp)) |
|
789 req.write(resp) |
784 |
790 |
785 elif cmd == 'changegroup': |
791 elif cmd == 'changegroup': |
786 req.httphdr("application/mercurial-0.1") |
792 req.httphdr("application/mercurial-0.1") |
787 nodes = [] |
793 nodes = [] |
788 if not self.allowpull: |
794 if not self.allowpull: |