Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_mod.py @ 2685:2edfd6644a9f
merge gitweb with crew
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Thu, 27 Jul 2006 02:37:04 +0200 |
parents | 109a22f5434a 783220e5d2d1 |
children | 046a8b03ea59 |
comparison
equal
deleted
inserted
replaced
2682:4e2dc5c16e61 | 2685:2edfd6644a9f |
---|---|
46 if mtime != self.mtime: | 46 if mtime != self.mtime: |
47 self.mtime = mtime | 47 self.mtime = mtime |
48 self.repo = hg.repository(self.repo.ui, self.repo.root) | 48 self.repo = hg.repository(self.repo.ui, self.repo.root) |
49 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) | 49 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) |
50 self.stripecount = int(self.repo.ui.config("web", "stripes", 1)) | 50 self.stripecount = int(self.repo.ui.config("web", "stripes", 1)) |
51 self.maxshortchanges = int(self.repo.ui.config("web", "maxshortchanges", 60)) | |
51 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) | 52 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) |
52 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) | 53 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
53 | 54 |
54 def archivelist(self, nodeid): | 55 def archivelist(self, nodeid): |
55 allowed = self.repo.ui.configlist("web", "allow_archive") | 56 allowed = self.repo.ui.configlist("web", "allow_archive") |
158 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, | 159 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
159 showfunc=showfunc, ignorews=ignorews, | 160 showfunc=showfunc, ignorews=ignorews, |
160 ignorewsamount=ignorewsamount, | 161 ignorewsamount=ignorewsamount, |
161 ignoreblanklines=ignoreblanklines), f, tn) | 162 ignoreblanklines=ignoreblanklines), f, tn) |
162 | 163 |
163 def changelog(self, pos): | 164 def changelog(self, pos, shortlog=False): |
164 def changenav(**map): | 165 def changenav(**map): |
165 def seq(factor, maxchanges=None): | 166 def seq(factor, maxchanges=None): |
166 if maxchanges: | 167 if maxchanges: |
167 yield maxchanges | 168 yield maxchanges |
168 if maxchanges >= 20 and maxchanges <= 40: | 169 if maxchanges >= 20 and maxchanges <= 40: |
173 for f in seq(factor * 10): | 174 for f in seq(factor * 10): |
174 yield f | 175 yield f |
175 | 176 |
176 l = [] | 177 l = [] |
177 last = 0 | 178 last = 0 |
178 for f in seq(1, self.maxchanges): | 179 maxchanges = shortlog and self.maxshortchanges or self.maxchanges |
179 if f < self.maxchanges or f <= last: | 180 for f in seq(1, maxchanges): |
181 if f < maxchanges or f <= last: | |
180 continue | 182 continue |
181 if f > count: | 183 if f > count: |
182 break | 184 break |
183 last = f | 185 last = f |
184 r = "%d" % f | 186 r = "%d" % f |
219 parity = 1 - parity | 221 parity = 1 - parity |
220 | 222 |
221 for e in l: | 223 for e in l: |
222 yield e | 224 yield e |
223 | 225 |
226 maxchanges = shortlog and self.maxshortchanges or self.maxchanges | |
224 cl = self.repo.changelog | 227 cl = self.repo.changelog |
225 mf = cl.read(cl.tip())[0] | 228 mf = cl.read(cl.tip())[0] |
226 count = cl.count() | 229 count = cl.count() |
227 start = max(0, pos - self.maxchanges + 1) | 230 start = max(0, pos - maxchanges + 1) |
228 end = min(count, start + self.maxchanges) | 231 end = min(count, start + maxchanges) |
229 pos = end - 1 | 232 pos = end - 1 |
230 | 233 |
231 yield self.t('changelog', | 234 yield self.t(shortlog and 'shortlog' or 'changelog', |
232 changenav=changenav, | 235 changenav=changenav, |
233 manifest=hex(mf), | 236 manifest=hex(mf), |
234 rev=pos, changesets=count, entries=changelist, | 237 rev=pos, changesets=count, entries=changelist, |
235 archives=self.archivelist("tip")) | 238 archives=self.archivelist("tip")) |
236 | 239 |
609 self.repo.ui.config("web", "contact") or # deprecated | 612 self.repo.ui.config("web", "contact") or # deprecated |
610 self.repo.ui.config("web", "author", "unknown")), # also | 613 self.repo.ui.config("web", "author", "unknown")), # also |
611 lastchange = (0, 0), # FIXME | 614 lastchange = (0, 0), # FIXME |
612 manifest = hex(mf), | 615 manifest = hex(mf), |
613 tags = tagentries, | 616 tags = tagentries, |
614 shortlog = changelist) | 617 shortlog = changelist, |
618 archives=self.archivelist("tip")) | |
615 | 619 |
616 def filediff(self, file, changeset): | 620 def filediff(self, file, changeset): |
617 cl = self.repo.changelog | 621 cl = self.repo.changelog |
618 n = self.repo.lookup(changeset) | 622 n = self.repo.lookup(changeset) |
619 changeset = hex(n) | 623 changeset = hex(n) |
689 **map) | 693 **map) |
690 | 694 |
691 def expand_form(form): | 695 def expand_form(form): |
692 shortcuts = { | 696 shortcuts = { |
693 'cl': [('cmd', ['changelog']), ('rev', None)], | 697 'cl': [('cmd', ['changelog']), ('rev', None)], |
698 'sl': [('cmd', ['shortlog']), ('rev', None)], | |
694 'cs': [('cmd', ['changeset']), ('node', None)], | 699 'cs': [('cmd', ['changeset']), ('node', None)], |
695 'f': [('cmd', ['file']), ('filenode', None)], | 700 'f': [('cmd', ['file']), ('filenode', None)], |
696 'fl': [('cmd', ['filelog']), ('filenode', None)], | 701 'fl': [('cmd', ['filelog']), ('filenode', None)], |
697 'fd': [('cmd', ['filediff']), ('node', None)], | 702 'fd': [('cmd', ['filediff']), ('node', None)], |
698 'fa': [('cmd', ['annotate']), ('filenode', None)], | 703 'fa': [('cmd', ['annotate']), ('filenode', None)], |
770 except hg.RepoError: | 775 except hg.RepoError: |
771 req.write(self.search(hi)) # XXX redirect to 404 page? | 776 req.write(self.search(hi)) # XXX redirect to 404 page? |
772 return | 777 return |
773 | 778 |
774 req.write(self.changelog(hi)) | 779 req.write(self.changelog(hi)) |
780 | |
781 def do_shortlog(self, req): | |
782 hi = self.repo.changelog.count() - 1 | |
783 if req.form.has_key('rev'): | |
784 hi = req.form['rev'][0] | |
785 try: | |
786 hi = self.repo.changelog.rev(self.repo.lookup(hi)) | |
787 except hg.RepoError: | |
788 req.write(self.search(hi)) # XXX redirect to 404 page? | |
789 return | |
790 | |
791 req.write(self.changelog(hi, shortlog = True)) | |
775 | 792 |
776 def do_changeset(self, req): | 793 def do_changeset(self, req): |
777 req.write(self.changeset(req.form['node'][0])) | 794 req.write(self.changeset(req.form['node'][0])) |
778 | 795 |
779 def do_manifest(self, req): | 796 def do_manifest(self, req): |