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