Show More
@@ -158,7 +158,7 b' class hgweb:' | |||
|
158 | 158 | self.mtime = -1 |
|
159 | 159 | self.reponame = name or self.repo.ui.config("web", "name", |
|
160 | 160 | self.repo.root) |
|
161 |
self. |
|
|
161 | self.archives = 'zip', 'gz', 'bz2' | |
|
162 | 162 | |
|
163 | 163 | def refresh(self): |
|
164 | 164 | s = os.stat(os.path.join(self.repo.root, ".hg", "00changelog.i")) |
@@ -168,10 +168,6 b' class hgweb:' | |||
|
168 | 168 | self.maxchanges = self.repo.ui.config("web", "maxchanges", 10) |
|
169 | 169 | self.maxfiles = self.repo.ui.config("web", "maxchanges", 10) |
|
170 | 170 | self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
|
171 | self.allowedtarballs = [] | |
|
172 | for i in self.supportedtarballs: | |
|
173 | if self.repo.ui.configbool("web", i, True): | |
|
174 | self.allowedtarballs.append(i) | |
|
175 | 171 | |
|
176 | 172 | def date(self, cs): |
|
177 | 173 | return time.asctime(time.gmtime(float(cs[2].split(' ')[0]))) |
@@ -395,10 +391,10 b' class hgweb:' | |||
|
395 | 391 | def diff(**map): |
|
396 | 392 | yield self.diff(p1, n, None) |
|
397 | 393 | |
|
398 |
def |
|
|
399 |
for i in self.a |
|
|
400 | yield {"type" : i, | |
|
401 | "manifest" : hex(changes[0])} | |
|
394 | def archivelist(): | |
|
395 | for i in self.archives: | |
|
396 | if self.repo.ui.configbool("web", "allow" + i, False): | |
|
397 | yield {"type" : i, "node" : nodeid} | |
|
402 | 398 | |
|
403 | 399 | yield self.t('changeset', |
|
404 | 400 | diff=diff, |
@@ -412,7 +408,7 b' class hgweb:' | |||
|
412 | 408 | desc=changes[4], |
|
413 | 409 | date=t, |
|
414 | 410 | files=files, |
|
415 |
|
|
|
411 | archives=archivelist()) | |
|
416 | 412 | |
|
417 | 413 | def filelog(self, f, filenode): |
|
418 | 414 | cl = self.repo.changelog |
@@ -640,52 +636,45 b' class hgweb:' | |||
|
640 | 636 | cl.parents(n), cl.rev), |
|
641 | 637 | diff=diff) |
|
642 | 638 | |
|
643 |
def |
|
|
639 | def archive(self, cnode, type): | |
|
640 | cs = self.repo.changelog.read(cnode) | |
|
641 | mnode = cs[0] | |
|
642 | mf = self.repo.manifest.read(mnode) | |
|
643 | rev = self.repo.manifest.rev(mnode) | |
|
644 | reponame = re.sub(r"\W+", "-", self.reponame) | |
|
645 | name = "%s-%s/" % (reponame, short(cnode)) | |
|
646 | ||
|
644 | 647 | if type == 'zip': |
|
645 | 648 | import zipfile |
|
646 | 649 | |
|
647 | tmp = tempfile.mkstemp()[1] | |
|
648 | zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) | |
|
649 | mf = self.repo.manifest.read(bin(mnode)) | |
|
650 | rev = self.repo.manifest.rev(bin(mnode)) | |
|
651 | cnode = short(self.repo.changelog.node(rev)) | |
|
652 | name = os.path.basename(self.repo.path[:-4]) # without '/.hg' suffix | |
|
653 | name += '-' + str(rev) + '-' + cnode + '/' | |
|
650 | try: | |
|
651 | tmp = tempfile.mkstemp()[1] | |
|
652 | zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) | |
|
653 | ||
|
654 | for f in mf.keys(): | |
|
655 | zf.writestr(name + f, self.repo.file(f).read(mf[f])) | |
|
656 | zf.close() | |
|
654 | 657 | |
|
655 | for fname in mf.keys(): | |
|
656 | r = self.repo.file(fname) | |
|
657 | zf.writestr(name + fname, r.read(mf[fname])) | |
|
658 | zf.close() | |
|
659 | ||
|
660 | f = open(tmp, 'r') | |
|
661 | httphdr('application/zip', name[:-1] + '.zip', os.path.getsize(tmp)) | |
|
662 | sys.stdout.write(f.read()) | |
|
663 | f.close() | |
|
664 | os.unlink(tmp) | |
|
658 | f = open(tmp, 'r') | |
|
659 | httphdr('application/zip', name[:-1] + '.zip', | |
|
660 | os.path.getsize(tmp)) | |
|
661 | sys.stdout.write(f.read()) | |
|
662 | f.close() | |
|
663 | finally: | |
|
664 | os.unlink(tmp) | |
|
665 | 665 | |
|
666 | 666 | else: |
|
667 | 667 | import StringIO |
|
668 | 668 | import time |
|
669 | 669 | import tarfile |
|
670 | 670 | |
|
671 | #if type == "gz": | |
|
672 | # tf = tarfile.TarFile.gzopen('', 'w', sys.stdout, compressionlevel) | |
|
673 | #else: | |
|
674 | # tf = tarfile.TarFile.bz2open('', 'w', sys.stdout, compressionlevel) | |
|
675 | 671 | tf = tarfile.TarFile.open(mode='w|' + type, fileobj=sys.stdout) |
|
676 | ||
|
677 | mf = self.repo.manifest.read(bin(mnode)) | |
|
678 | rev = self.repo.manifest.rev(bin(mnode)) | |
|
679 | cnode = short(self.repo.changelog.node(rev)) | |
|
680 | mff = self.repo.manifest.readflags(bin(mnode)) | |
|
672 | mff = self.repo.manifest.readflags(mnode) | |
|
681 | 673 | mtime = int(time.time()) |
|
682 | name = os.path.basename(self.repo.path[:-4]) # without '/.hg' suffix | |
|
683 | name += '-' + str(rev) + '-' + cnode + '/' | |
|
684 | 674 | |
|
685 | 675 | httphdr('application/octet-stream', name[:-1] + '.tar.' + type) |
|
686 | 676 | for fname in mf.keys(): |
|
687 | r = self.repo.file(fname) | |
|
688 | rcont = r.read(mf[fname]) | |
|
677 | rcont = self.repo.file(fname).read(mf[fname]) | |
|
689 | 678 | finfo = tarfile.TarInfo(name + fname) |
|
690 | 679 | finfo.mtime = mtime |
|
691 | 680 | finfo.size = len(rcont) |
@@ -810,13 +799,13 b' class hgweb:' | |||
|
810 | 799 | |
|
811 | 800 | sys.stdout.write(z.flush()) |
|
812 | 801 | |
|
813 |
elif args['cmd'][0] == ' |
|
|
814 |
|
|
|
802 | elif args['cmd'][0] == 'archive': | |
|
803 | changeset = bin(args['node'][0]) | |
|
815 | 804 | type = args['type'][0] |
|
816 |
f |
|
|
817 | if type == i and i in self.allowedtarballs: | |
|
818 |
|
|
|
819 |
|
|
|
805 | if (type in self.archives and | |
|
806 | self.repo.ui.configbool("web", "allow" + type, False)): | |
|
807 | self.archive(changeset, type) | |
|
808 | return | |
|
820 | 809 | |
|
821 | 810 | write(self.t("error")) |
|
822 | 811 |
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | <a href="?cmd=tags">tags</a> |
|
9 | 9 | <a href="?cmd=manifest;manifest=#manifest#;path=/">manifest</a> |
|
10 | 10 | <a href="?cmd=changeset;node=#node#;style=raw">raw</a> |
|
11 | #tarballs%tarballentry# | |
|
11 | #archives%archiveentry# | |
|
12 | 12 | </div> |
|
13 | 13 | |
|
14 | 14 | <h2>changeset: #desc|escape|firstline#</h2> |
General Comments 0
You need to be logged in to leave comments.
Login now