##// END OF EJS Templates
hgweb: fix handling of path for old style template...
Benoit Boissinot -
r3595:fc34fd58 default
parent child Browse files
Show More
@@ -441,13 +441,13 b' class hgweb(object):'
441
441
442 files = {}
442 files = {}
443
443
444 p = path[1:]
444 if path and path[-1] != "/":
445 if p and p[-1] != "/":
445 path += "/"
446 p += "/"
446 l = len(path)
447 l = len(p)
447 abspath = "/" + path
448
448
449 for f,n in mf.items():
449 for f,n in mf.items():
450 if f[:l] != p:
450 if f[:l] != path:
451 continue
451 continue
452 remain = f[l:]
452 remain = f[l:]
453 if "/" in remain:
453 if "/" in remain:
@@ -483,15 +483,15 b' class hgweb(object):'
483 continue
483 continue
484
484
485 yield {"parity": self.stripes(parity),
485 yield {"parity": self.stripes(parity),
486 "path": os.path.join(path, f),
486 "path": os.path.join(abspath, f),
487 "basename": f[:-1]}
487 "basename": f[:-1]}
488 parity += 1
488 parity += 1
489
489
490 yield self.t("manifest",
490 yield self.t("manifest",
491 rev=ctx.rev(),
491 rev=ctx.rev(),
492 node=hex(node),
492 node=hex(node),
493 path=path,
493 path=abspath,
494 up=_up(path),
494 up=_up(abspath),
495 fentries=filelist,
495 fentries=filelist,
496 dentries=dirlist,
496 dentries=dirlist,
497 archives=self.archivelist(hex(node)))
497 archives=self.archivelist(hex(node)))
@@ -639,6 +639,7 b' class hgweb(object):'
639 # find tag, changeset, file
639 # find tag, changeset, file
640
640
641 def cleanpath(self, path):
641 def cleanpath(self, path):
642 path = path.lstrip('/')
642 return util.canonpath(self.repo.root, '', path)
643 return util.canonpath(self.repo.root, '', path)
643
644
644 def run(self):
645 def run(self):
@@ -865,16 +866,15 b' class hgweb(object):'
865 self.do_changeset(req)
866 self.do_changeset(req)
866
867
867 def do_file(self, req):
868 def do_file(self, req):
868 path = req.form.get('file', [''])[0]
869 path = self.cleanpath(req.form.get('file', [''])[0])
869 if path:
870 if path:
870 try:
871 try:
871 req.write(self.filerevision(self.filectx(req)))
872 req.write(self.filerevision(self.filectx(req)))
872 return
873 return
873 except hg.RepoError:
874 except hg.RepoError:
874 pass
875 pass
875 path = self.cleanpath(path)
876
876
877 req.write(self.manifest(self.changectx(req), '/' + path))
877 req.write(self.manifest(self.changectx(req), path))
878
878
879 def do_diff(self, req):
879 def do_diff(self, req):
880 self.do_filediff(req)
880 self.do_filediff(req)
General Comments 0
You need to be logged in to leave comments. Login now