Mercurial > hg-stable
changeset 6442:fa5454a451c6
merge with crew-stable
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 01 Apr 2008 08:34:23 +0200 |
parents | c9b8f2820bc0 (diff) a60b711c7ac4 (current diff) |
children | 34eeb891d227 |
files | mercurial/commands.py |
diffstat | 43 files changed, 1844 insertions(+), 727 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/dumprevlog Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# Dump revlogs as raw data stream +# $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump + +import sys +from mercurial import revlog, node + +for f in sys.argv[1:]: + r = revlog.revlog(open, f) + print "file:", f + for i in xrange(r.count()): + n = r.node(i) + p = r.parents(n) + d = r.revision(n) + print "node:", node.hex(n) + print "linkrev:", r.linkrev(n) + print "parents:", node.hex(p[0]), node.hex(p[1]) + print "length:", len(d) + print "-start-" + print d + print "-end-"
--- a/contrib/mercurial.el Tue Apr 01 08:33:17 2008 +0200 +++ b/contrib/mercurial.el Tue Apr 01 08:34:23 2008 +0200 @@ -35,8 +35,10 @@ ;; This code has been developed under XEmacs 21.5, and may not work as ;; well under GNU Emacs (albeit tested under 21.4). Patches to ;; enhance the portability of this code, fix bugs, and add features -;; are most welcome. You can clone a Mercurial repository for this -;; package from http://www.serpentine.com/hg/hg-emacs +;; are most welcome. + +;; As of version 22.3, GNU Emacs's VC mode has direct support for +;; Mercurial, so this package may not prove as useful there. ;; Please send problem reports and suggestions to bos@serpentine.com.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/undumprevlog Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Undump a dump from dumprevlog +# $ hg init +# $ undumprevlog < repo.dump + +import sys +from mercurial import revlog, node, util, transaction + +opener = util.opener('.', False) +tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") +while 1: + l = sys.stdin.readline() + if not l: + break + if l.startswith("file:"): + f = l[6:-1] + r = revlog.revlog(opener, f) + print f + elif l.startswith("node:"): + n = node.bin(l[6:-1]) + elif l.startswith("linkrev:"): + lr = int(l[9:-1]) + elif l.startswith("parents:"): + p = l[9:-1].split() + p1 = node.bin(p[0]) + p2 = node.bin(p[1]) + elif l.startswith("length:"): + length = int(l[8:-1]) + sys.stdin.readline() # start marker + d = sys.stdin.read(length) + sys.stdin.readline() # end marker + r.addrevision(d, tr, lr, p1, p2) + +tr.close()
--- a/hgext/convert/subversion.py Tue Apr 01 08:33:17 2008 +0200 +++ b/hgext/convert/subversion.py Tue Apr 01 08:34:23 2008 +0200 @@ -387,7 +387,7 @@ try: for entry in get_log(self.url, [self.tags], start, self.startrev): origpaths, revnum, author, date, message = entry - copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p,e + copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e in origpaths.iteritems() if e.copyfrom_path] copies.sort() # Apply moves/copies from more specific to general
--- a/hgext/highlight.py Tue Apr 01 08:33:17 2008 +0200 +++ b/hgext/highlight.py Tue Apr 01 08:34:23 2008 +0200 @@ -20,18 +20,13 @@ # pygmentize -f html -S <newstyle> - -- Adam Hupp <adam@hupp.org> - - """ from mercurial import demandimport -demandimport.ignore.extend(['pkgutil', - 'pkg_resources', - '__main__',]) +demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',]) -from mercurial.hgweb.hgweb_mod import hgweb +from mercurial.hgweb import webcommands, webutil from mercurial import util from mercurial.templatefilters import filters @@ -43,7 +38,8 @@ SYNTAX_CSS = ('\n<link rel="stylesheet" href="#staticurl#highlight.css" ' 'type="text/css" />') -def pygmentize(self, tmpl, fctx, field): +def pygmentize(field, fctx, style, tmpl): + # append a <link ...> to the syntax highlighting css old_header = ''.join(tmpl('header')) if SYNTAX_CSS not in old_header: @@ -54,7 +50,6 @@ if util.binary(text): return - style = self.config("web", "pygments_style", "colorful") # To get multi-line strings right, we can't format line-by-line try: lexer = guess_lexer_for_filename(fctx.path(), text, @@ -79,20 +74,21 @@ newl = oldl.replace('line|escape', 'line|colorize') tmpl.cache[field] = newl -def filerevision_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'fileline') - - return realrevision(self, tmpl, fctx) +web_filerevision = webcommands._filerevision +web_annotate = webcommands.annotate -def fileannotate_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'annotateline') +def filerevision_highlight(web, tmpl, fctx): + style = web.config('web', 'pygments_style', 'colorful') + pygmentize('fileline', fctx, style, tmpl) + return web_filerevision(web, tmpl, fctx) - return realannotate(self, tmpl, fctx) +def annotate_highlight(web, req, tmpl): + fctx = webutil.filectx(web.repo, req) + style = web.config('web', 'pygments_style', 'colorful') + pygmentize('annotateline', fctx, style, tmpl) + return web_annotate(web, req, tmpl) # monkeypatch in the new version -# should be safer than overriding the method in a derived class -# and then patching the class -realrevision = hgweb.filerevision -hgweb.filerevision = filerevision_highlight -realannotate = hgweb.fileannotate -hgweb.fileannotate = fileannotate_highlight + +webcommands._filerevision = filerevision_highlight +webcommands.annotate = annotate_highlight
--- a/hgext/keyword.py Tue Apr 01 08:33:17 2008 +0200 +++ b/hgext/keyword.py Tue Apr 01 08:34:23 2008 +0200 @@ -108,6 +108,8 @@ _patchfile_init = patch.patchfile.__init__ _patch_diff = patch.diff _dispatch_parse = dispatch._parse +_webcommands_changeset = webcommands.changeset +_webcommands_filediff = webcommands.filediff def _kwpatchfile_init(self, ui, fname, missing=False): '''Monkeypatch/wrap patch.patchfile.__init__ to avoid @@ -131,12 +133,12 @@ def _kwweb_changeset(web, req, tmpl): '''Wraps webcommands.changeset turning off keyword expansion.''' kwtools['templater'].matcher = util.never - return web.changeset(tmpl, web.changectx(req)) + return _webcommands_changeset(web, req, tmpl) def _kwweb_filediff(web, req, tmpl): '''Wraps webcommands.filediff turning off keyword expansion.''' kwtools['templater'].matcher = util.never - return web.filediff(tmpl, web.filectx(req)) + return _webcommands_filediff(web, req, tmpl) def _kwdispatch_parse(ui, args): '''Monkeypatch dispatch._parse to obtain running hg command.''' @@ -145,6 +147,7 @@ return cmd, func, args, options, cmdoptions # dispatch._parse is run before reposetup, so wrap it here +# all other actual monkey patching is done at end of reposetup dispatch._parse = _kwdispatch_parse
--- a/hgext/pager.py Tue Apr 01 08:33:17 2008 +0200 +++ b/hgext/pager.py Tue Apr 01 08:34:23 2008 +0200 @@ -24,12 +24,37 @@ # # [pager] # quiet = True +# +# You can disable the pager for certain commands by adding them to the +# pager.ignore list: +# +# [pager] +# ignore = version, help, update +# +# You can also enable the pager only for certain commands using pager.attend: +# +# [pager] +# attend = log +# +# If pager.attend is present, pager.ignore will be ignored. +# +# To ignore global commands like 'hg version' or 'hg help', you have to specify them +# in the global .hgrc import sys, os, signal +from mercurial import dispatch def uisetup(ui): - p = ui.config("pager", "pager", os.environ.get("PAGER")) - if p and sys.stdout.isatty(): - if ui.configbool('pager', 'quiet'): - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - sys.stderr = sys.stdout = os.popen(p, "wb") + def pagecmd(ui, options, cmd, cmdfunc): + p = ui.config("pager", "pager", os.environ.get("PAGER")) + if p and sys.stdout.isatty(): + attend = ui.configlist('pager', 'attend') + if (cmd in attend or + (cmd not in ui.configlist('pager', 'ignore') and not attend)): + sys.stderr = sys.stdout = os.popen(p, "wb") + if ui.configbool('pager', 'quiet'): + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + return oldrun(ui, options, cmd, cmdfunc) + + oldrun = dispatch._runcommand + dispatch._runcommand = pagecmd
--- a/mercurial/commands.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/commands.py Tue Apr 01 08:34:23 2008 +0200 @@ -2530,8 +2530,17 @@ if port == ':80': port = '' - ui.status(_('listening at http://%s%s/%s (%s:%d)\n') % - (self.httpd.fqaddr, port, prefix, self.httpd.addr, self.httpd.port)) + bindaddr = self.httpd.addr + if bindaddr == '0.0.0.0': + bindaddr = '*' + elif ':' in bindaddr: # IPv6 + bindaddr = '[%s]' % bindaddr + + fqaddr = self.httpd.fqaddr + if ':' in fqaddr: + fqaddr = '[%s]' % fqaddr + ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') % + (fqaddr, port, prefix, bindaddr, self.httpd.port)) def run(self): self.httpd.serve_forever()
--- a/mercurial/hgweb/hgweb_mod.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/hgweb/hgweb_mod.py Tue Apr 01 08:34:23 2008 +0200 @@ -6,16 +6,15 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes, re, mimetools, cStringIO -from mercurial.node import hex, nullid, short +import os, mimetypes +from mercurial.node import hex, nullid from mercurial.repo import RepoError -from mercurial import mdiff, ui, hg, util, archival, patch, hook +from mercurial import mdiff, ui, hg, util, patch, hook from mercurial import revlog, templater, templatefilters, changegroup -from common import get_mtime, style_map, paritygen, countgen, get_contact -from common import ErrorResponse +from common import get_mtime, style_map, paritygen, countgen, ErrorResponse from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR from request import wsgirequest -import webcommands, protocol +import webcommands, protocol, webutil shortcuts = { 'cl': [('cmd', ['changelog']), ('rev', None)], @@ -32,54 +31,6 @@ 'static': [('cmd', ['static']), ('file', None)] } -def _up(p): - if p[0] != "/": - p = "/" + p - if p[-1] == "/": - p = p[:-1] - up = os.path.dirname(p) - if up == "/": - return "/" - return up + "/" - -def revnavgen(pos, pagelen, limit, nodefunc): - def seq(factor, limit=None): - if limit: - yield limit - if limit >= 20 and limit <= 40: - yield 50 - else: - yield 1 * factor - yield 3 * factor - for f in seq(factor * 10): - yield f - - def nav(**map): - l = [] - last = 0 - for f in seq(1, pagelen): - if f < pagelen or f <= last: - continue - if f > limit: - break - last = f - if pos + f < limit: - l.append(("+%d" % f, hex(nodefunc(pos + f).node()))) - if pos - f >= 0: - l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) - - try: - yield {"label": "(0)", "node": hex(nodefunc('0').node())} - - for label, node in l: - yield {"label": label, "node": node} - - yield {"label": "tip", "node": "tip"} - except RepoError: - pass - - return nav - class hgweb(object): def __init__(self, repo, name=None): if isinstance(repo, str): @@ -226,17 +177,8 @@ try: tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=self.encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=self.encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=self.encoding) + ctype = templater.stringify(ctype) if cmd == '': req.form['cmd'] = [tmpl.cache['default']] @@ -291,13 +233,7 @@ # some functions for the templater def header(**map): - header = tmpl('header', encoding=self.encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=self.encoding, **map) def footer(**map): yield tmpl("footer", **map) @@ -355,54 +291,6 @@ if len(files) > self.maxfiles: yield tmpl("fileellipses") - def siblings(self, siblings=[], hiderev=None, **args): - siblings = [s for s in siblings if s.node() != nullid] - if len(siblings) == 1 and siblings[0].rev() == hiderev: - return - for s in siblings: - d = {'node': hex(s.node()), 'rev': s.rev()} - if hasattr(s, 'path'): - d['file'] = s.path() - d.update(args) - yield d - - def renamelink(self, fl, node): - r = fl.renamed(node) - if r: - return [dict(file=r[0], node=hex(r[1]))] - return [] - - def nodetagsdict(self, node): - return [{"name": i} for i in self.repo.nodetags(node)] - - def nodebranchdict(self, ctx): - branches = [] - branch = ctx.branch() - # If this is an empty repo, ctx.node() == nullid, - # ctx.branch() == 'default', but branchtags() is - # an empty dict. Using dict.get avoids a traceback. - if self.repo.branchtags().get(branch) == ctx.node(): - branches.append({"name": branch}) - return branches - - def nodeinbranch(self, ctx): - branches = [] - branch = ctx.branch() - if branch != 'default' and self.repo.branchtags().get(branch) != ctx.node(): - branches.append({"name": branch}) - return branches - - def nodebranchnodefault(self, ctx): - branches = [] - branch = ctx.branch() - if branch != 'default': - branches.append({"name": branch}) - return branches - - def showtag(self, tmpl, t1, node=nullid, **args): - for t in self.repo.nodetags(node): - yield tmpl(t1, tag=t, **args) - def diff(self, tmpl, node1, node2, files): def filterfiles(filters, files): l = [x for x in files if x in filters] @@ -470,514 +358,12 @@ yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, opts=diffopts), f, tn) - def changelog(self, tmpl, ctx, shortlog=False): - def changelist(limit=0,**map): - cl = self.repo.changelog - l = [] # build a list in forward order for efficiency - for i in xrange(start, end): - ctx = self.repo.changectx(i) - n = ctx.node() - showtags = self.showtag(tmpl, 'changelogtag', n) - - l.insert(0, {"parity": parity.next(), - "author": ctx.user(), - "parent": self.siblings(ctx.parents(), i - 1), - "child": self.siblings(ctx.children(), i + 1), - "changelogtag": showtags, - "desc": ctx.description(), - "date": ctx.date(), - "files": self.listfilediffs(tmpl, ctx.files(), n), - "rev": i, - "node": hex(n), - "tags": self.nodetagsdict(n), - "inbranch": self.nodeinbranch(ctx), - "branches": self.nodebranchdict(ctx)}) - - if limit > 0: - l = l[:limit] - - for e in l: - yield e - - maxchanges = shortlog and self.maxshortchanges or self.maxchanges - cl = self.repo.changelog - count = cl.count() - pos = ctx.rev() - start = max(0, pos - maxchanges + 1) - end = min(count, start + maxchanges) - pos = end - 1 - parity = paritygen(self.stripecount, offset=start-end) - - changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) - - return tmpl(shortlog and 'shortlog' or 'changelog', - changenav=changenav, - node=hex(cl.tip()), - rev=pos, changesets=count, - entries=lambda **x: changelist(limit=0,**x), - latestentry=lambda **x: changelist(limit=1,**x), - archives=self.archivelist("tip")) - - def search(self, tmpl, query): - - def changelist(**map): - cl = self.repo.changelog - count = 0 - qw = query.lower().split() - - def revgen(): - for i in xrange(cl.count() - 1, 0, -100): - l = [] - for j in xrange(max(0, i - 100), i + 1): - ctx = self.repo.changectx(j) - l.append(ctx) - l.reverse() - for e in l: - yield e - - for ctx in revgen(): - miss = 0 - for q in qw: - if not (q in ctx.user().lower() or - q in ctx.description().lower() or - q in " ".join(ctx.files()).lower()): - miss = 1 - break - if miss: - continue - - count += 1 - n = ctx.node() - showtags = self.showtag(tmpl, 'changelogtag', n) - - yield tmpl('searchentry', - parity=parity.next(), - author=ctx.user(), - parent=self.siblings(ctx.parents()), - child=self.siblings(ctx.children()), - changelogtag=showtags, - desc=ctx.description(), - date=ctx.date(), - files=self.listfilediffs(tmpl, ctx.files(), n), - rev=ctx.rev(), - node=hex(n), - tags=self.nodetagsdict(n), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - if count >= self.maxchanges: - break - - cl = self.repo.changelog - parity = paritygen(self.stripecount) - - return tmpl('search', - query=query, - node=hex(cl.tip()), - entries=changelist, - archives=self.archivelist("tip")) - - def changeset(self, tmpl, ctx): - n = ctx.node() - showtags = self.showtag(tmpl, 'changesettag', n) - parents = ctx.parents() - p1 = parents[0].node() - - files = [] - parity = paritygen(self.stripecount) - for f in ctx.files(): - files.append(tmpl("filenodelink", - node=hex(n), file=f, - parity=parity.next())) - - def diff(**map): - yield self.diff(tmpl, p1, n, None) - - return tmpl('changeset', - diff=diff, - rev=ctx.rev(), - node=hex(n), - parent=self.siblings(parents), - child=self.siblings(ctx.children()), - changesettag=showtags, - author=ctx.user(), - desc=ctx.description(), - date=ctx.date(), - files=files, - archives=self.archivelist(hex(n)), - tags=self.nodetagsdict(n), - branch=self.nodebranchnodefault(ctx), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - def filelog(self, tmpl, fctx): - f = fctx.path() - fl = fctx.filelog() - count = fl.count() - pagelen = self.maxshortchanges - pos = fctx.filerev() - start = max(0, pos - pagelen + 1) - end = min(count, start + pagelen) - pos = end - 1 - parity = paritygen(self.stripecount, offset=start-end) - - def entries(limit=0, **map): - l = [] - - for i in xrange(start, end): - ctx = fctx.filectx(i) - n = fl.node(i) - - l.insert(0, {"parity": parity.next(), - "filerev": i, - "file": f, - "node": hex(ctx.node()), - "author": ctx.user(), - "date": ctx.date(), - "rename": self.renamelink(fl, n), - "parent": self.siblings(fctx.parents()), - "child": self.siblings(fctx.children()), - "desc": ctx.description()}) - - if limit > 0: - l = l[:limit] - - for e in l: - yield e - - nodefunc = lambda x: fctx.filectx(fileid=x) - nav = revnavgen(pos, pagelen, count, nodefunc) - return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, - entries=lambda **x: entries(limit=0, **x), - latestentry=lambda **x: entries(limit=1, **x)) - - def filerevision(self, tmpl, fctx): - f = fctx.path() - text = fctx.data() - fl = fctx.filelog() - n = fctx.filenode() - parity = paritygen(self.stripecount) - - if util.binary(text): - mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' - text = '(binary:%s)' % mt - - def lines(): - for lineno, t in enumerate(text.splitlines(1)): - yield {"line": t, - "lineid": "l%d" % (lineno + 1), - "linenumber": "% 6d" % (lineno + 1), - "parity": parity.next()} - - return tmpl("filerevision", - file=f, - path=_up(f), - text=lines(), - rev=fctx.rev(), - node=hex(fctx.node()), - author=fctx.user(), - date=fctx.date(), - desc=fctx.description(), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(fctx.parents()), - child=self.siblings(fctx.children()), - rename=self.renamelink(fl, n), - permissions=fctx.manifest().flags(f)) - - def fileannotate(self, tmpl, fctx): - f = fctx.path() - n = fctx.filenode() - fl = fctx.filelog() - parity = paritygen(self.stripecount) - - def annotate(**map): - last = None - if util.binary(fctx.data()): - mt = (mimetypes.guess_type(fctx.path())[0] - or 'application/octet-stream') - lines = enumerate([((fctx.filectx(fctx.filerev()), 1), - '(binary:%s)' % mt)]) - else: - lines = enumerate(fctx.annotate(follow=True, linenumber=True)) - for lineno, ((f, targetline), l) in lines: - fnode = f.filenode() - name = self.repo.ui.shortuser(f.user()) - - if last != fnode: - last = fnode - - yield {"parity": parity.next(), - "node": hex(f.node()), - "rev": f.rev(), - "author": name, - "file": f.path(), - "targetline": targetline, - "line": l, - "lineid": "l%d" % (lineno + 1), - "linenumber": "% 6d" % (lineno + 1)} - - return tmpl("fileannotate", - file=f, - annotate=annotate, - path=_up(f), - rev=fctx.rev(), - node=hex(fctx.node()), - author=fctx.user(), - date=fctx.date(), - desc=fctx.description(), - rename=self.renamelink(fl, n), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(fctx.parents()), - child=self.siblings(fctx.children()), - permissions=fctx.manifest().flags(f)) - - def manifest(self, tmpl, ctx, path): - mf = ctx.manifest() - node = ctx.node() - - files = {} - parity = paritygen(self.stripecount) - - if path and path[-1] != "/": - path += "/" - l = len(path) - abspath = "/" + path - - for f, n in mf.items(): - if f[:l] != path: - continue - remain = f[l:] - if "/" in remain: - short = remain[:remain.index("/") + 1] # bleah - files[short] = (f, None) - else: - short = os.path.basename(remain) - files[short] = (f, n) - - if not files: - raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) - - def filelist(**map): - fl = files.keys() - fl.sort() - for f in fl: - full, fnode = files[f] - if not fnode: - continue - - fctx = ctx.filectx(full) - yield {"file": full, - "parity": parity.next(), - "basename": f, - "date": fctx.changectx().date(), - "size": fctx.size(), - "permissions": mf.flags(full)} - - def dirlist(**map): - fl = files.keys() - fl.sort() - for f in fl: - full, fnode = files[f] - if fnode: - continue - - yield {"parity": parity.next(), - "path": "%s%s" % (abspath, f), - "basename": f[:-1]} - - return tmpl("manifest", - rev=ctx.rev(), - node=hex(node), - path=abspath, - up=_up(abspath), - upparity=parity.next(), - fentries=filelist, - dentries=dirlist, - archives=self.archivelist(hex(node)), - tags=self.nodetagsdict(node), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - def tags(self, tmpl): - i = self.repo.tagslist() - i.reverse() - parity = paritygen(self.stripecount) - - def entries(notip=False,limit=0, **map): - count = 0 - for k, n in i: - if notip and k == "tip": - continue - if limit > 0 and count >= limit: - continue - count = count + 1 - yield {"parity": parity.next(), - "tag": k, - "date": self.repo.changectx(n).date(), - "node": hex(n)} - - return tmpl("tags", - node=hex(self.repo.changelog.tip()), - entries=lambda **x: entries(False,0, **x), - entriesnotip=lambda **x: entries(True,0, **x), - latestentry=lambda **x: entries(True,1, **x)) - - def summary(self, tmpl): - i = self.repo.tagslist() - i.reverse() - - def tagentries(**map): - parity = paritygen(self.stripecount) - count = 0 - for k, n in i: - if k == "tip": # skip tip - continue; - - count += 1 - if count > 10: # limit to 10 tags - break; - - yield tmpl("tagentry", - parity=parity.next(), - tag=k, - node=hex(n), - date=self.repo.changectx(n).date()) - - - def branches(**map): - parity = paritygen(self.stripecount) - - b = self.repo.branchtags() - l = [(-self.repo.changelog.rev(n), n, t) for t, n in b.items()] - l.sort() - - for r,n,t in l: - ctx = self.repo.changectx(n) - - yield {'parity': parity.next(), - 'branch': t, - 'node': hex(n), - 'date': ctx.date()} - - def changelist(**map): - parity = paritygen(self.stripecount, offset=start-end) - l = [] # build a list in forward order for efficiency - for i in xrange(start, end): - ctx = self.repo.changectx(i) - n = ctx.node() - hn = hex(n) - - l.insert(0, tmpl( - 'shortlogentry', - parity=parity.next(), - author=ctx.user(), - desc=ctx.description(), - date=ctx.date(), - rev=i, - node=hn, - tags=self.nodetagsdict(n), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx))) - - yield l - - cl = self.repo.changelog - count = cl.count() - start = max(0, count - self.maxchanges) - end = min(count, start + self.maxchanges) - - return tmpl("summary", - desc=self.config("web", "description", "unknown"), - owner=get_contact(self.config) or "unknown", - lastchange=cl.read(cl.tip())[2], - tags=tagentries, - branches=branches, - shortlog=changelist, - node=hex(cl.tip()), - archives=self.archivelist("tip")) - - def filediff(self, tmpl, fctx): - n = fctx.node() - path = fctx.path() - parents = fctx.parents() - p1 = parents and parents[0].node() or nullid - - def diff(**map): - yield self.diff(tmpl, p1, n, [path]) - - return tmpl("filediff", - file=path, - node=hex(n), - rev=fctx.rev(), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(parents), - child=self.siblings(fctx.children()), - diff=diff) - archive_specs = { 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), 'zip': ('application/zip', 'zip', '.zip', None), } - def archive(self, tmpl, req, key, type_): - reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) - cnode = self.repo.lookup(key) - arch_version = key - if cnode == key or key == 'tip': - arch_version = short(cnode) - name = "%s-%s" % (reponame, arch_version) - mimetype, artype, extension, encoding = self.archive_specs[type_] - headers = [ - ('Content-Type', mimetype), - ('Content-Disposition', 'attachment; filename=%s%s' % - (name, extension)) - ] - if encoding: - headers.append(('Content-Encoding', encoding)) - req.header(headers) - req.respond(HTTP_OK) - archival.archive(self.repo, req, cnode, artype, prefix=name) - - # add tags to things - # tags -> list of changesets corresponding to tags - # find tag, changeset, file - - def cleanpath(self, path): - path = path.lstrip('/') - return util.canonpath(self.repo.root, '', path) - - def changectx(self, req): - if 'node' in req.form: - changeid = req.form['node'][0] - elif 'manifest' in req.form: - changeid = req.form['manifest'][0] - else: - changeid = self.repo.changelog.count() - 1 - - try: - ctx = self.repo.changectx(changeid) - except RepoError: - man = self.repo.manifest - mn = man.lookup(changeid) - ctx = self.repo.changectx(man.linkrev(mn)) - - return ctx - - def filectx(self, req): - path = self.cleanpath(req.form['file'][0]) - if 'node' in req.form: - changeid = req.form['node'][0] - else: - changeid = req.form['filenode'][0] - try: - ctx = self.repo.changectx(changeid) - fctx = ctx.filectx(path) - except RepoError: - fctx = self.repo.filectx(path, fileid=changeid) - - return fctx - def check_perm(self, req, op, default): '''check permission for operation based on user auth. return true if op allowed, else false.
--- a/mercurial/hgweb/hgwebdir_mod.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Apr 01 08:34:23 2008 +0200 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetools, cStringIO +import os from mercurial.i18n import gettext as _ from mercurial.repo import RepoError from mercurial import ui, hg, util, templater, templatefilters @@ -81,17 +81,8 @@ virtual = req.env.get("PATH_INFO", "").strip('/') tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=util._encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=util._encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=util._encoding) + ctype = templater.stringify(ctype) # a static file if virtual.startswith('static/') or 'static' in req.form: @@ -255,13 +246,7 @@ def templater(self, req): def header(**map): - header = tmpl('header', encoding=util._encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=util._encoding, **map) def footer(**map): yield tmpl("footer", **map)
--- a/mercurial/hgweb/server.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/hgweb/server.py Tue Apr 01 08:34:23 2008 +0200 @@ -268,12 +268,7 @@ self.addr, self.port = self.socket.getsockname()[0:2] self.prefix = prefix - self.fqaddr = socket.getfqdn(address) - try: - socket.getaddrbyhost(self.fqaddr) - except: - fqaddr = address class IPv6HTTPServer(MercurialHTTPServer): address_family = getattr(socket, 'AF_INET6', None)
--- a/mercurial/hgweb/webcommands.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/hgweb/webcommands.py Tue Apr 01 08:34:23 2008 +0200 @@ -5,10 +5,14 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes -from mercurial import revlog, util +import os, mimetypes, re +import webutil +from mercurial import revlog, archival +from mercurial.node import short, hex, nullid +from mercurial.util import binary from mercurial.repo import RepoError -from common import staticfile, ErrorResponse, HTTP_OK, HTTP_NOT_FOUND +from common import paritygen, staticfile, get_contact, ErrorResponse +from common import HTTP_OK, HTTP_NOT_FOUND # __all__ is populated with the allowed commands. Be sure to add to it if # you're adding a new command, or the new command won't work. @@ -26,17 +30,17 @@ return changelog(web, req, tmpl) def rawfile(web, req, tmpl): - path = web.cleanpath(req.form.get('file', [''])[0]) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) if not path: - content = web.manifest(tmpl, web.changectx(req), path) + content = manifest(web, req, tmpl) req.respond(HTTP_OK, web.ctype) return content try: - fctx = web.filectx(req) + fctx = webutil.filectx(web.repo, req) except revlog.LookupError, inst: try: - content = web.manifest(tmpl, web.changectx(req), path) + content = manifest(web, req, tmpl) req.respond(HTTP_OK, web.ctype) return content except ErrorResponse: @@ -45,28 +49,120 @@ path = fctx.path() text = fctx.data() mt = mimetypes.guess_type(path)[0] - if mt is None or util.binary(text): + if mt is None or binary(text): mt = mt or 'application/octet-stream' req.respond(HTTP_OK, mt, path, len(text)) return [text] +def _filerevision(web, tmpl, fctx): + f = fctx.path() + text = fctx.data() + fl = fctx.filelog() + n = fctx.filenode() + parity = paritygen(web.stripecount) + + if binary(text): + mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' + text = '(binary:%s)' % mt + + def lines(): + for lineno, t in enumerate(text.splitlines(1)): + yield {"line": t, + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1), + "parity": parity.next()} + + return tmpl("filerevision", + file=f, + path=webutil.up(f), + text=lines(), + rev=fctx.rev(), + node=hex(fctx.node()), + author=fctx.user(), + date=fctx.date(), + desc=fctx.description(), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(fctx.parents()), + child=webutil.siblings(fctx.children()), + rename=webutil.renamelink(fctx), + permissions=fctx.manifest().flags(f)) + def file(web, req, tmpl): - path = web.cleanpath(req.form.get('file', [''])[0]) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) if path: try: - return web.filerevision(tmpl, web.filectx(req)) + return _filerevision(web, tmpl, webutil.filectx(web.repo, req)) except revlog.LookupError, inst: pass try: - return web.manifest(tmpl, web.changectx(req), path) + return manifest(web, req, tmpl) except ErrorResponse: raise inst +def _search(web, tmpl, query): + + def changelist(**map): + cl = web.repo.changelog + count = 0 + qw = query.lower().split() + + def revgen(): + for i in xrange(cl.count() - 1, 0, -100): + l = [] + for j in xrange(max(0, i - 100), i + 1): + ctx = web.repo.changectx(j) + l.append(ctx) + l.reverse() + for e in l: + yield e + + for ctx in revgen(): + miss = 0 + for q in qw: + if not (q in ctx.user().lower() or + q in ctx.description().lower() or + q in " ".join(ctx.files()).lower()): + miss = 1 + break + if miss: + continue + + count = 1 + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) + + yield tmpl('searchentry', + parity=parity.next(), + author=ctx.user(), + parent=webutil.siblings(ctx.parents()), + child=webutil.siblings(ctx.children()), + changelogtag=showtags, + desc=ctx.description(), + date=ctx.date(), + files=web.listfilediffs(tmpl, ctx.files(), n), + rev=ctx.rev(), + node=hex(n), + tags=webutil.nodetagsdict(web.repo, n), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) + + if count >= web.maxchanges: + break + + cl = web.repo.changelog + parity = paritygen(web.stripecount) + + return tmpl('search', + query=query, + node=hex(cl.tip()), + entries=changelist, + archives=web.archivelist("tip")) + def changelog(web, req, tmpl, shortlog = False): if 'node' in req.form: - ctx = web.changectx(req) + ctx = webutil.changectx(web.repo, req) else: if 'rev' in req.form: hi = req.form['rev'][0] @@ -75,47 +171,400 @@ try: ctx = web.repo.changectx(hi) except RepoError: - return web.search(tmpl, hi) # XXX redirect to 404 page? + return _search(web, tmpl, hi) # XXX redirect to 404 page? + + def changelist(limit=0, **map): + cl = web.repo.changelog + l = [] # build a list in forward order for efficiency + for i in xrange(start, end): + ctx = web.repo.changectx(i) + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) + + l.insert(0, {"parity": parity.next(), + "author": ctx.user(), + "parent": webutil.siblings(ctx.parents(), i - 1), + "child": webutil.siblings(ctx.children(), i + 1), + "changelogtag": showtags, + "desc": ctx.description(), + "date": ctx.date(), + "files": web.listfilediffs(tmpl, ctx.files(), n), + "rev": i, + "node": hex(n), + "tags": webutil.nodetagsdict(web.repo, n), + "inbranch": webutil.nodeinbranch(web.repo, ctx), + "branches": webutil.nodebranchdict(web.repo, ctx) + }) - return web.changelog(tmpl, ctx, shortlog = shortlog) + if limit > 0: + l = l[:limit] + + for e in l: + yield e + + maxchanges = shortlog and web.maxshortchanges or web.maxchanges + cl = web.repo.changelog + count = cl.count() + pos = ctx.rev() + start = max(0, pos - maxchanges + 1) + end = min(count, start + maxchanges) + pos = end - 1 + parity = paritygen(web.stripecount, offset=start-end) + + changenav = webutil.revnavgen(pos, maxchanges, count, web.repo.changectx) + + return tmpl(shortlog and 'shortlog' or 'changelog', + changenav=changenav, + node=hex(ctx.node()), + rev=pos, changesets=count, + entries=lambda **x: changelist(limit=0,**x), + latestentry=lambda **x: changelist(limit=1,**x), + archives=web.archivelist("tip")) def shortlog(web, req, tmpl): return changelog(web, req, tmpl, shortlog = True) def changeset(web, req, tmpl): - return web.changeset(tmpl, web.changectx(req)) + ctx = webutil.changectx(web.repo, req) + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changesettag', n) + parents = ctx.parents() + p1 = parents[0].node() + + files = [] + parity = paritygen(web.stripecount) + for f in ctx.files(): + files.append(tmpl("filenodelink", + node=hex(n), file=f, + parity=parity.next())) + + diffs = web.diff(tmpl, p1, n, None) + return tmpl('changeset', + diff=diffs, + rev=ctx.rev(), + node=hex(n), + parent=webutil.siblings(parents), + child=webutil.siblings(ctx.children()), + changesettag=showtags, + author=ctx.user(), + desc=ctx.description(), + date=ctx.date(), + files=files, + archives=web.archivelist(hex(n)), + tags=webutil.nodetagsdict(web.repo, n), + branch=webutil.nodebranchnodefault(ctx), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) rev = changeset def manifest(web, req, tmpl): - return web.manifest(tmpl, web.changectx(req), - web.cleanpath(req.form['path'][0])) + ctx = webutil.changectx(web.repo, req) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) + mf = ctx.manifest() + node = ctx.node() + + files = {} + parity = paritygen(web.stripecount) + + if path and path[-1] != "/": + path += "/" + l = len(path) + abspath = "/" + path + + for f, n in mf.items(): + if f[:l] != path: + continue + remain = f[l:] + if "/" in remain: + short = remain[:remain.index("/") + 1] # bleah + files[short] = (f, None) + else: + short = os.path.basename(remain) + files[short] = (f, n) + + if not files: + raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) + + def filelist(**map): + fl = files.keys() + fl.sort() + for f in fl: + full, fnode = files[f] + if not fnode: + continue + + fctx = ctx.filectx(full) + yield {"file": full, + "parity": parity.next(), + "basename": f, + "date": fctx.changectx().date(), + "size": fctx.size(), + "permissions": mf.flags(full)} + + def dirlist(**map): + fl = files.keys() + fl.sort() + for f in fl: + full, fnode = files[f] + if fnode: + continue + + yield {"parity": parity.next(), + "path": "%s%s" % (abspath, f), + "basename": f[:-1]} + + return tmpl("manifest", + rev=ctx.rev(), + node=hex(node), + path=abspath, + up=webutil.up(abspath), + upparity=parity.next(), + fentries=filelist, + dentries=dirlist, + archives=web.archivelist(hex(node)), + tags=webutil.nodetagsdict(web.repo, node), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) def tags(web, req, tmpl): - return web.tags(tmpl) + i = web.repo.tagslist() + i.reverse() + parity = paritygen(web.stripecount) + + def entries(notip=False,limit=0, **map): + count = 0 + for k, n in i: + if notip and k == "tip": + continue + if limit > 0 and count >= limit: + continue + count = count + 1 + yield {"parity": parity.next(), + "tag": k, + "date": web.repo.changectx(n).date(), + "node": hex(n)} + + return tmpl("tags", + node=hex(web.repo.changelog.tip()), + entries=lambda **x: entries(False,0, **x), + entriesnotip=lambda **x: entries(True,0, **x), + latestentry=lambda **x: entries(True,1, **x)) def summary(web, req, tmpl): - return web.summary(tmpl) + i = web.repo.tagslist() + i.reverse() + + def tagentries(**map): + parity = paritygen(web.stripecount) + count = 0 + for k, n in i: + if k == "tip": # skip tip + continue + + count = 1 + if count > 10: # limit to 10 tags + break + + yield tmpl("tagentry", + parity=parity.next(), + tag=k, + node=hex(n), + date=web.repo.changectx(n).date()) + + def branches(**map): + parity = paritygen(web.stripecount) + + b = web.repo.branchtags() + l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()] + l.sort() + + for r,n,t in l: + ctx = web.repo.changectx(n) + yield {'parity': parity.next(), + 'branch': t, + 'node': hex(n), + 'date': ctx.date()} + + def changelist(**map): + parity = paritygen(web.stripecount, offset=start-end) + l = [] # build a list in forward order for efficiency + for i in xrange(start, end): + ctx = web.repo.changectx(i) + n = ctx.node() + hn = hex(n) + + l.insert(0, tmpl( + 'shortlogentry', + parity=parity.next(), + author=ctx.user(), + desc=ctx.description(), + date=ctx.date(), + rev=i, + node=hn, + tags=webutil.nodetagsdict(web.repo, n), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx))) + + yield l + + cl = web.repo.changelog + count = cl.count() + start = max(0, count - web.maxchanges) + end = min(count, start + web.maxchanges) + + return tmpl("summary", + desc=web.config("web", "description", "unknown"), + owner=get_contact(web.config) or "unknown", + lastchange=cl.read(cl.tip())[2], + tags=tagentries, + branches=branches, + shortlog=changelist, + node=hex(cl.tip()), + archives=web.archivelist("tip")) def filediff(web, req, tmpl): - return web.filediff(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + n = fctx.node() + path = fctx.path() + parents = fctx.parents() + p1 = parents and parents[0].node() or nullid + + diffs = web.diff(tmpl, p1, n, [path]) + return tmpl("filediff", + file=path, + node=hex(n), + rev=fctx.rev(), + date=fctx.date(), + desc=fctx.description(), + author=fctx.user(), + rename=webutil.renamelink(fctx), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(parents), + child=webutil.siblings(fctx.children()), + diff=diffs) diff = filediff def annotate(web, req, tmpl): - return web.fileannotate(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + f = fctx.path() + n = fctx.filenode() + fl = fctx.filelog() + parity = paritygen(web.stripecount) + + def annotate(**map): + last = None + if binary(fctx.data()): + mt = (mimetypes.guess_type(fctx.path())[0] + or 'application/octet-stream') + lines = enumerate([((fctx.filectx(fctx.filerev()), 1), + '(binary:%s)' % mt)]) + else: + lines = enumerate(fctx.annotate(follow=True, linenumber=True)) + for lineno, ((f, targetline), l) in lines: + fnode = f.filenode() + name = web.repo.ui.shortuser(f.user()) + + if last != fnode: + last = fnode + + yield {"parity": parity.next(), + "node": hex(f.node()), + "rev": f.rev(), + "author": name, + "file": f.path(), + "targetline": targetline, + "line": l, + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1)} + + return tmpl("fileannotate", + file=f, + annotate=annotate, + path=webutil.up(f), + rev=fctx.rev(), + node=hex(fctx.node()), + author=fctx.user(), + date=fctx.date(), + desc=fctx.description(), + rename=webutil.renamelink(fctx), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(fctx.parents()), + child=webutil.siblings(fctx.children()), + permissions=fctx.manifest().flags(f)) def filelog(web, req, tmpl): - return web.filelog(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + f = fctx.path() + fl = fctx.filelog() + count = fl.count() + pagelen = web.maxshortchanges + pos = fctx.filerev() + start = max(0, pos - pagelen + 1) + end = min(count, start + pagelen) + pos = end - 1 + parity = paritygen(web.stripecount, offset=start-end) + + def entries(limit=0, **map): + l = [] + + for i in xrange(start, end): + ctx = fctx.filectx(i) + n = fl.node(i) + + l.insert(0, {"parity": parity.next(), + "filerev": i, + "file": f, + "node": hex(ctx.node()), + "author": ctx.user(), + "date": ctx.date(), + "rename": webutil.renamelink(fctx), + "parent": webutil.siblings(fctx.parents()), + "child": webutil.siblings(fctx.children()), + "desc": ctx.description()}) + + if limit > 0: + l = l[:limit] + + for e in l: + yield e + + nodefunc = lambda x: fctx.filectx(fileid=x) + nav = webutil.revnavgen(pos, pagelen, count, nodefunc) + return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, + entries=lambda **x: entries(limit=0, **x), + latestentry=lambda **x: entries(limit=1, **x)) + def archive(web, req, tmpl): type_ = req.form['type'][0] allowed = web.configlist("web", "allow_archive") - if (type_ in web.archives and (type_ in allowed or + key = req.form['node'][0] + + if not (type_ in web.archives and (type_ in allowed or web.configbool("web", "allow" + type_, False))): - web.archive(tmpl, req, req.form['node'][0], type_) - return [] - raise ErrorResponse(HTTP_NOT_FOUND, 'unsupported archive type: %s' % type_) + msg = 'Unsupported archive type: %s' % type_ + raise ErrorResponse(HTTP_NOT_FOUND, msg) + + reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) + cnode = web.repo.lookup(key) + arch_version = key + if cnode == key or key == 'tip': + arch_version = short(cnode) + name = "%s-%s" % (reponame, arch_version) + mimetype, artype, extension, encoding = web.archive_specs[type_] + headers = [ + ('Content-Type', mimetype), + ('Content-Disposition', 'attachment; filename=%s%s' % (name, extension)) + ] + if encoding: + headers.append(('Content-Encoding', encoding)) + req.header(headers) + req.respond(HTTP_OK) + archival.archive(web.repo, req, cnode, artype, prefix=name) + return [] + def static(web, req, tmpl): fname = req.form['file'][0]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/hgweb/webutil.py Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,143 @@ +# hgweb/webutil.py - utility library for the web interface. +# +# Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> +# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +import os +from mercurial.node import hex, nullid +from mercurial.repo import RepoError +from mercurial import util + +def up(p): + if p[0] != "/": + p = "/" + p + if p[-1] == "/": + p = p[:-1] + up = os.path.dirname(p) + if up == "/": + return "/" + return up + "/" + +def revnavgen(pos, pagelen, limit, nodefunc): + def seq(factor, limit=None): + if limit: + yield limit + if limit >= 20 and limit <= 40: + yield 50 + else: + yield 1 * factor + yield 3 * factor + for f in seq(factor * 10): + yield f + + def nav(**map): + l = [] + last = 0 + for f in seq(1, pagelen): + if f < pagelen or f <= last: + continue + if f > limit: + break + last = f + if pos + f < limit: + l.append(("+%d" % f, hex(nodefunc(pos + f).node()))) + if pos - f >= 0: + l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) + + try: + yield {"label": "(0)", "node": hex(nodefunc('0').node())} + + for label, node in l: + yield {"label": label, "node": node} + + yield {"label": "tip", "node": "tip"} + except RepoError: + pass + + return nav + +def siblings(siblings=[], hiderev=None, **args): + siblings = [s for s in siblings if s.node() != nullid] + if len(siblings) == 1 and siblings[0].rev() == hiderev: + return + for s in siblings: + d = {'node': hex(s.node()), 'rev': s.rev()} + if hasattr(s, 'path'): + d['file'] = s.path() + d.update(args) + yield d + +def renamelink(fctx): + r = fctx.renamed() + if r: + return [dict(file=r[0], node=hex(r[1]))] + return [] + +def nodetagsdict(repo, node): + return [{"name": i} for i in repo.nodetags(node)] + +def nodebranchdict(repo, ctx): + branches = [] + branch = ctx.branch() + # If this is an empty repo, ctx.node() == nullid, + # ctx.branch() == 'default', but branchtags() is + # an empty dict. Using dict.get avoids a traceback. + if repo.branchtags().get(branch) == ctx.node(): + branches.append({"name": branch}) + return branches + +def nodeinbranch(repo, ctx): + branches = [] + branch = ctx.branch() + if branch != 'default' and repo.branchtags().get(branch) != ctx.node(): + branches.append({"name": branch}) + return branches + +def nodebranchnodefault(ctx): + branches = [] + branch = ctx.branch() + if branch != 'default': + branches.append({"name": branch}) + return branches + +def showtag(repo, tmpl, t1, node=nullid, **args): + for t in repo.nodetags(node): + yield tmpl(t1, tag=t, **args) + +def cleanpath(repo, path): + path = path.lstrip('/') + return util.canonpath(repo.root, '', path) + +def changectx(repo, req): + if 'node' in req.form: + changeid = req.form['node'][0] + elif 'manifest' in req.form: + changeid = req.form['manifest'][0] + else: + changeid = repo.changelog.count() - 1 + + try: + ctx = repo.changectx(changeid) + except RepoError: + man = repo.manifest + mn = man.lookup(changeid) + ctx = repo.changectx(man.linkrev(mn)) + + return ctx + +def filectx(repo, req): + path = cleanpath(repo, req.form['file'][0]) + if 'node' in req.form: + changeid = req.form['node'][0] + else: + changeid = req.form['filenode'][0] + try: + ctx = repo.changectx(changeid) + fctx = ctx.filectx(path) + except RepoError: + fctx = repo.filectx(path, fileid=changeid) + + return fctx
--- a/mercurial/manifest.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/manifest.py Tue Apr 01 08:34:23 2008 +0200 @@ -8,7 +8,7 @@ from node import bin, hex, nullid from revlog import revlog, RevlogError from i18n import _ -import array, struct, mdiff +import array, struct, mdiff, parsers class manifestdict(dict): def __init__(self, mapping=None, flags=None): @@ -39,14 +39,7 @@ def parse(self, lines): mfdict = manifestdict() - fdict = mfdict._flags - for l in lines.splitlines(): - f, n = l.split('\0') - if len(n) > 40: - fdict[f] = n[40:] - mfdict[f] = bin(n[:40]) - else: - mfdict[f] = bin(n) + parsers.parse_manifest(mfdict, mfdict._flags, lines) return mfdict def readdelta(self, node):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/parsers.c Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,169 @@ +/* + parsers.c - efficient content parsing + + Copyright 2008 Matt Mackall <mpm@selenic.com> and others + + This software may be used and distributed according to the terms of + the GNU General Public License, incorporated herein by reference. +*/ + +#include <Python.h> +#include <ctype.h> +#include <string.h> + +static int hexdigit(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + + return -1; +} + +/* + * Turn a hex-encoded string into binary. + */ +static PyObject *unhexlify(const char *str, int len) +{ + PyObject *ret = NULL; + const char *c; + char *d; + + if (len % 2) { + PyErr_SetString(PyExc_ValueError, + "input is not even in length"); + goto bail; + } + + ret = PyString_FromStringAndSize(NULL, len / 2); + if (!ret) + goto bail; + + d = PyString_AsString(ret); + if (!d) + goto bail; + + for (c = str; c < str + len;) { + int hi = hexdigit(*c++); + int lo = hexdigit(*c++); + + if (hi == -1 || lo == -1) { + PyErr_SetString(PyExc_ValueError, + "input contains non-hex character"); + goto bail; + } + + *d++ = (hi << 4) | lo; + } + + goto done; + +bail: + Py_XDECREF(ret); + ret = NULL; +done: + return ret; +} + +/* + * This code assumes that a manifest is stitched together with newline + * ('\n') characters. + */ +static PyObject *parse_manifest(PyObject *self, PyObject *args) +{ + PyObject *mfdict, *fdict; + char *str, *cur, *start, *zero; + int len; + + if (!PyArg_ParseTuple(args, "O!O!s#:parse_manifest", + &PyDict_Type, &mfdict, + &PyDict_Type, &fdict, + &str, &len)) + goto quit; + + for (start = cur = str, zero = NULL; cur < str + len; cur++) { + PyObject *file = NULL, *node = NULL; + PyObject *flags = NULL; + int nlen; + + if (!*cur) { + zero = cur; + continue; + } + else if (*cur != '\n') + continue; + + if (!zero) { + PyErr_SetString(PyExc_ValueError, + "manifest entry has no separator"); + goto quit; + } + + file = PyString_FromStringAndSize(start, zero - start); + if (!file) + goto bail; + + nlen = cur - zero - 1; + + node = unhexlify(zero + 1, nlen > 40 ? 40 : nlen); + if (!node) + goto bail; + + if (nlen > 40) { + PyObject *flags; + + flags = PyString_FromStringAndSize(zero + 41, + nlen - 40); + if (!flags) + goto bail; + + if (PyDict_SetItem(fdict, file, flags) == -1) + goto bail; + } + + if (PyDict_SetItem(mfdict, file, node) == -1) + goto bail; + + start = cur + 1; + zero = NULL; + + Py_XDECREF(flags); + Py_XDECREF(node); + Py_XDECREF(file); + continue; + bail: + Py_XDECREF(flags); + Py_XDECREF(node); + Py_XDECREF(file); + goto quit; + } + + if (len > 0 && *(cur - 1) != '\n') { + PyErr_SetString(PyExc_ValueError, + "manifest contains trailing garbage"); + goto quit; + } + + Py_INCREF(Py_None); + return Py_None; + +quit: + return NULL; +} + +static char parsers_doc[] = "Efficient content parsing."; + +static PyMethodDef methods[] = { + {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"}, + {NULL, NULL} +}; + +PyMODINIT_FUNC initparsers(void) +{ + Py_InitModule3("parsers", methods, parsers_doc); +}
--- a/mercurial/repair.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/repair.py Tue Apr 01 08:34:23 2008 +0200 @@ -72,7 +72,6 @@ def strip(ui, repo, node, backup="all"): cl = repo.changelog # TODO delete the undo files, and handle undo of merge sets - pp = cl.parents(node) striprev = cl.rev(node) # Some revisions with rev > striprev may not be descendants of striprev.
--- a/mercurial/templater.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/templater.py Tue Apr 01 08:34:23 2008 +0200 @@ -114,7 +114,7 @@ v = v(**map) if format: if not hasattr(v, '__iter__'): - raise SyntaxError(_("Error expanding '%s%s'") + raise SyntaxError(_("Error expanding '%s%%%s'") % (key, format)) lm = map.copy() for i in v:
--- a/mercurial/transaction.py Tue Apr 01 08:33:17 2008 +0200 +++ b/mercurial/transaction.py Tue Apr 01 08:34:23 2008 +0200 @@ -96,9 +96,13 @@ files = {} for l in open(file).readlines(): f, o = l.split('\0') - files[f] = o + files[f] = int(o) for f in files: o = files[f] - opener(f, "a").truncate(int(o)) + if o: + opener(f, "a").truncate(int(o)) + else: + fn = opener(f).name + os.unlink(fn) os.unlink(file)
--- a/setup.py Tue Apr 01 08:33:17 2008 +0200 +++ b/setup.py Tue Apr 01 08:34:23 2008 +0200 @@ -88,10 +88,11 @@ cmdclass = {'install_data': install_package_data} ext_modules=[ - Extension('mercurial.mpatch', ['mercurial/mpatch.c']), + Extension('mercurial.base85', ['mercurial/base85.c']), Extension('mercurial.bdiff', ['mercurial/bdiff.c']), - Extension('mercurial.base85', ['mercurial/base85.c']), - Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']) + Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), + Extension('mercurial.mpatch', ['mercurial/mpatch.c']), + Extension('mercurial.parsers', ['mercurial/parsers.c']), ] packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert']
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/changelog.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,41 @@ +{header} +<title>{repo|escape}: changelog</title> +<link rel="alternate" type="application/atom+xml" + href="{url}atom-log" title="Atom feed for {repo|escape}"> +<link rel="alternate" type="application/rss+xml" + href="{url}rss-log" title="RSS feed for {repo|escape}"> +</head> +<body> + +<div class="buttons"> +<a href="{url}shortlog/{rev}{sessionvars%urlparameter}">shortlog</a> +<a href="{url}tags{sessionvars%urlparameter}">tags</a> +<a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a> +{archives%archiveentry} +<a type="application/rss+xml" href="{url}rss-log">rss</a> +<a type="application/atom+xml" href="{url}atom-log" title="Atom feed for {repo|escape}">atom</a> +</div> + +<h2>changelog for {repo|escape}</h2> + +<form action="{url}log"> +{sessionvars%hiddenformentry} +<p> +<label for="search1">search:</label> +<input name="rev" id="search1" type="text" size="30"> +navigate: <small class="navigate">{changenav%naventry}</small> +</p> +</form> + +{entries%changelogentry} + +<form action="{url}log"> +{sessionvars%hiddenformentry} +<p> +<label for="search2">search:</label> +<input name="rev" id="search2" type="text" size="30"> +navigate: <small class="navigate">{changenav%naventry}</small> +</p> +</form> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/changelogentry.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,25 @@ +<table class="logEntry parity{parity}"> + <tr> + <th class="age">{date|age} ago:</th> + <th class="firstline">{desc|strip|firstline|escape}</th> + </tr> + <tr> + <th class="revision">changeset {rev}:</th> + <td class="node"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td> + </tr> + {parent%changelogparent} + {child%changelogchild} + {changelogtag} + <tr> + <th class="author">author:</th> + <td class="author">{author|obfuscate}</td> + </tr> + <tr> + <th class="date">date:</th> + <td class="date">{date|date}</td> + </tr> + <tr> + <th class="files"><a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>:</th> + <td class="files">{files}</td> + </tr> +</table>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/changeset.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,70 @@ +{header} +<title>{repo|escape}: {node|short}</title> +</head> +<body> +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> + <li><a href="{url}shortlog{sessionvars%urlparameter}">log</a></li> + <li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +<ul> + <li class="active">changeset</li> + <li><a href="{url}file/{node|short}{sessionvars%urlparameter}">browse</a></li> +</ul> +<ul> + {archives%archiveentry}</ul> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>changeset {node|short} {changesettag}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="description">{desc|strip|escape|addbreaks}</div> + +<table id="changesetEntry"> +<tr> + <th class="author">author</th> + <td class="author">{author|obfuscate}</td> +</tr> +<tr> + <th class="date">date</th> + <td class="date">{date|date} ({date|age} ago)</td></tr> +<tr> + <th class="author">parents</th> + <td class="author">{parent%changesetparent}</td> +</tr> +<tr> + <th class="author">children</th> + <td class="author">{child%changesetchild}</td> +</tr> +<tr> + <th class="files">files</th> + <td class="files">{files}</td></tr> +</tr> +</table> +<tr> + +<div class="overflow"> +<table class="bigtable"> +<tr> + <th class="lineno">Line</th> + <th class="source">Diff</th> +</tr> +</table> +{diff} +</div> + +{footer} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/error.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,37 @@ +{header} +<title>{repo|escape}: error</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}log{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>error</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="description"> +<p> +An error occurred while processing your request: +</p> +<p> +{error|escape} +</p> +</div> +</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/fileannotate.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,74 @@ +{header} +<title>{repo|escape}: {file|escape} annotate</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog/{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> + +<ul> +<li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li> +<li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li> +</ul> +<ul> +<li><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li> +<li><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a></li> +<li class="active">annotate</li> +<li><a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file log</a></li> +<li><a href="{url}raw-annotate/{node|short}/{file|urlescape}">raw</a></li> +</ul> +</div> + +<div class="main"> +<h2>{repo|escape}</h2> +<h3>Annotate {file|escape} @ {node|short}</h2> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="description">{desc|strip|escape|addbreaks}</div> + +<table id="changesetEntry"> +<tr> + <th class="author">author</th> + <td class="author">{author|obfuscate}</td> +</tr> +<tr> + <th class="date">date</th> + <td class="date">{date|date} ({date|age} ago)</td> +</tr> +<tr> + <th class="author">parents</th> + <td class="author">{parent%filerevparent}</td> +</tr> +<tr> + <th class="author">children</th> + <td class="author">{child%filerevchild}</td> +</tr> +{changesettag} +</table> + +<br/> + +<div class="overflow"> +<table class="bigtable"> +<tr> + <th class="annotate">Rev</th> + <th class="lineno">Line</th> + <th class="line">Source</th> +</tr> +{annotate%annotateline} +</table> +</div> + +</div> +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/filediff.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,72 @@ +{header} +<title>{repo|escape}: {file|escape} diff</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog/{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +<ul> +<li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li> +<li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li> +</ul> +<ul> +<li><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li> +<li class="active">diff</li> +<li><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a></li> +<li><a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file log</a></li> +<li><a href="{url}raw-file/{node|short}/{file|urlescape}">raw</a></li> +</ul> +</div> + +<div class="main"> +<h2>{repo|escape}</h2> +<h3>diff {file|escape} @ {node|short}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="description">{desc|strip|escape|addbreaks}</div> + +<table id="changesetEntry"> +<tr> + <th>author</th> + <td>{author|obfuscate}</td> +</tr> +<tr> + <th>date</th> + <td>{date|date} ({date|age} ago)</td> +</tr> +<tr> + <th>parents</th> + <td>{parent%filerevparent}</td> +</tr> +<tr> + <th>children</th> + <td>{child%filerevchild}</td> +</tr> +{changesettag} +</table> + +<div class="overflow"> +<table class="bigtable"> +<tr> + <th class="lineno">Line</th> + <th class="source">Diff</th> +</tr> +<table> +{diff} +</div> +</div> + +{footer} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/filelog.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,56 @@ +{header} +<title>{repo|escape}: {file|escape} history</title> +<link rel="alternate" type="application/atom+xml" + href="{url}atom-log/tip/{file|urlescape}" title="Atom feed for {repo|escape}:{file}"> +<link rel="alternate" type="application/rss+xml" + href="{url}rss-log/tip/{file|urlescape}" title="RSS feed for {repo|escape}:{file}"> +</head> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog/{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +<ul> +<li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li> +<li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li> +</ul> +<ul> +<li><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li> +<li><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a></li> +<li><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a></li> +<li class="active">file log</li> +<li><a href="{url}raw-file/{node|short}/{file|urlescape}">raw</a></li> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>log {file|escape} @ {node|short}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="navigate">{nav%filenaventry}</div> + +<table class="bigtable"> + <tr> + <th class="age">Age</td> + <th class="author">Author</td> + <th class="description">Description</td> + </tr> +{entries%filelogentry} +</table> + +</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/filelogentry.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,5 @@ + <tr class="parity{parity}"> + <td class="age">{date|age}</td> + <td class="author">{author|person}</td> + <td class="description"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{desc|strip|firstline|escape}</a></td> + </tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/filerevision.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,72 @@ +{header} +<title>{repo|escape}: {node|short} {file|escape}</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog/{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +<ul> +<li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li> +<li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">browse</a></li> +</ul> +<ul> +<li class="active">file</li> +<li><a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a></li> +<li><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a></li> +<li><a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a></li> +<li><a href="{url}raw-file/{node|short}/{file|urlescape}">raw</a></li> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>view {file|escape} @ {node|short}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="description">{desc|strip|escape|addbreaks}</div> + +<table id="changesetEntry"> +<tr> + <th class="author">author</th> + <td class="author">{author|obfuscate}</td> +</tr> +<tr> + <th class="date">date</th> + <td class="date">{date|date} ({date|age} ago)</td> +</tr> +<tr> + <th class="author">parents</th> + <td class="author">{parent%filerevparent}</td> +</tr> +<tr> + <th class="author">children</th> + <td class="author">{child%filerevchild}</td> +</tr> +{changesettag} +</table> + +<div class="overflow"> +<table class="bigtable"> +<tr> + <th class="lineno">Line</th> + <th class="source">Source</th> +</tr> +{text%fileline} +</table> +</div> + +</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/footer.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,4 @@ +{motd} + +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/header.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<link rel="icon" href="{staticurl}hgicon.png" type="image/png"> +<meta name="robots" content="index, nofollow" /> +<link rel="stylesheet" href="{staticurl}style-coal.css" type="text/css" />
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/index.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,19 @@ +{header} +<title>Mercurial repositories index</title> +</head> +<body> + +<h2>Mercurial Repositories</h2> + +<table> + <tr> + <td><a href="?sort={sort_name}">Name</a></td> + <td><a href="?sort={sort_description}">Description</a></td> + <td><a href="?sort={sort_contact}">Contact</a></td> + <td><a href="?sort={sort_lastchange}">Last change</a></td> + <td> </td> + <tr> + {entries%indexentry} +</table> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/manifest.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,51 @@ +{header} +<title>{repo|escape}: {node|short} {path|escape}</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog/{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +<ul> +<li><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a></li> +<li class="active">browse</li> +</ul> +<ul> +{archives%archiveentry} +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>directory {path|escape} @ {node|short} {tags%changelogtag}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<table class="bigtable"> +<tr> + <th class="permissions">permissions</th> + <th class="date">date</th> + <th class="size">size</th> + <th class="name">name</th> +</tr> +<tr class="parity{upparity}"> + <td class="permissions"><tt>drwxr-xr-x</tt> + <td class="date"> + <td class="size"> + <td class="name"><a href="{url}file/{node|short}{up|urlescape}{sessionvars%urlparameter}">[up]</a> +</tr> +{dentries%direntry} +{fentries%fileentry} +</table> +</main> +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/map Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,70 @@ +default = 'shortlog' + +mimetype = 'text/html; charset={encoding}' +header = header.tmpl +footer = footer.tmpl +search = search.tmpl + +changelog = changelog.tmpl + +shortlog = shortlog.tmpl +shortlogentry = shortlogentry.tmpl + +naventry = '<a href="{url}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> ' +navshortentry = '<a href="{url}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> ' +filenaventry = '<a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> ' +filedifflink = '<a href="{url}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> ' +filenodelink = '<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> ' +fileellipses = '...' +changelogentry = shortlogentry.tmpl +searchentry = shortlogentry.tmpl +changeset = changeset.tmpl +manifest = manifest.tmpl + +direntry = '<tr class="parity{parity}"><td class="permissions">drwxr-xr-x</td><td class="date"></td><td class="size"></td><td class="name"><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">{basename|escape}/</a></td></tr>' +fileentry = '<tr class="parity{parity}"><td class="permissions">{permissions|permissions} </td><td class="date">{date|isodate} </td><td class="size">{size} </td><td clase="filename"><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{basename|escape}</a></td></tr>' + +filerevision = filerevision.tmpl +fileannotate = fileannotate.tmpl +filediff = filediff.tmpl +filelog = filelog.tmpl +fileline = '<tr class="parity{parity}"><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source">{line|escape}</td></tr>' +filelogentry = filelogentry.tmpl + +annotateline = '<tr class="parity{parity}"><td class="annotate"><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}">{author|obfuscate}@{rev}</a></td><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source">{line|escape}</td></tr>' + +diffblock = '<table class="bigtable parity{parity}">{lines}</table>' +difflineplus = '<tr><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source plusline">{line|escape}</td></tr>' +difflineminus = '<tr><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source minusline">{line|escape}</td></tr>' +difflineat = '<tr><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source atline">{line|escape}</td></tr>' +diffline = '<tr><td class="lineno"><a href="#{lineid}" id="{lineid}">{linenumber}</a></td><td class="source">{line|escape}</td></tr>' + +changelogparent = '<tr><th class="parent">parent {rev}:</th><td class="parent"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>' + +changesetparent = '<a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> ' + +filerevparent = '<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> ' +filerevchild = '<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> ' + +filerename = '{file|escape}@' +filelogrename = '<tr><th>base:</th><td><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}@{node|short}</a></td></tr>' +fileannotateparent = '<tr><td class="metatag">parent:</td><td><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a></td></tr>' +changesetchild = '<a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>' +changelogchild = '<tr><th class="child">child</th><td class="child"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +fileannotatechild = '<tr><td class="metatag">child:</td><td><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +tags = tags.tmpl +tagentry = '<tr class="tagEntry parity{parity}"><td><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{tag|escape}</a></td><td class="node">{node|short}</td></tr>' +changelogtag = '<tr><th class="tag">tag:</th><td class="tag">{tag|escape}</td></tr>' +changelogtag = '<span class="tag">{name|escape}</span> ' +changesettag = '<span class="tag">{tag|escape}</span> ' +filediffparent = '<tr><th class="parent">parent {rev}:</th><td class="parent"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +filelogparent = '<tr><th>parent {rev}:</th><td><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +filediffchild = '<tr><th class="child">child {rev}:</th><td class="child"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +filelogchild = '<tr><th>child {rev}:</th><td><a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td></tr>' +indexentry = '<tr class="parity{parity}"><td><a href="{url}{sessionvars%urlparameter}">{name|escape}</a></td><td>{description}</td><td>{contact|obfuscate}</td><td class="age">{lastchange|age} ago</td><td class="indexlinks"><a href="{url}rss-log">RSS</a> <a href="{url}atom-log">Atom</a> {archives%archiveentry}</td></tr>' +index = index.tmpl +archiveentry = '<li><a href="{url}archive/{node|short}{extension|urlescape}">{type|escape}</a></li>' +notfound = notfound.tmpl +error = error.tmpl +urlparameter = '{separator}{name}={value|urlescape}' +hiddenformentry = '<input type="hidden" name="{name}" value="{value|escape}" />'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/notfound.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,12 @@ +{header} +<title>Mercurial repository not found</title> +</head> +<body> + +<h2>Mercurial repository not found</h2> + +The specified repository "{repo|escape}" is unknown, sorry. + +Please go back to the main repository list page. + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/search.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,38 @@ +{header} +<title>{repo|escape}: searching for {query|escape}</title> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog{sessionvars%urlparameter}">log</a></li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>searching for '{query|escape}'</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<table class="bigtable"> + <tr> + <th class="age">Age</td> + <th class="author">Author</td> + <th class="description">Description</td> + </tr> +{entries} +</table> + +</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/shortlog.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,44 @@ +{header} +<title>{repo|escape}: log</title> +<link rel="alternate" type="application/atom+xml" + href="{url}atom-log" title="Atom feed for {repo|escape}"> +<link rel="alternate" type="application/rss+xml" + href="{url}rss-log" title="RSS feed for {repo|escape}"> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li class="active">log</li> +<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li> +</ul> +</div> + +<div class="main"> + +<h2>{repo|escape}</h2> +<h3>log @ {node|short}</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<div class="navigate">{changenav%navshortentry}</div> + +<table class="bigtable"> + <tr> + <th class="age">Age</td> + <th class="author">Author</td> + <th class="description">Description</td> + </tr> +{entries%shortlogentry} +</table> + +<div class="navigate">{changenav%navshortentry}</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/shortlogentry.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,5 @@ + <tr class="parity{parity}"> + <td class="age">{date|age}</td> + <td class="author">{author|person}</td> + <td class="description"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{desc|strip|firstline|escape}</a>{tags%changelogtag}</td> + </tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/coal/tags.tmpl Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,39 @@ +{header} +<title>{repo|escape}: tags</title> +<link rel="alternate" type="application/atom+xml" + href="{url}atom-tags" title="Atom feed for {repo|escape}: tags"> +<link rel="alternate" type="application/rss+xml" + href="{url}rss-tags" title="RSS feed for {repo|escape}: tags"> +</head> +<body> + +<div class="menu"> +<div class="logo"> +<a href="http://www.selenic.com/mercurial/"> +<img src="{staticurl}hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> +</div> +<ul> +<li><a href="{url}shortlog{sessionvars%urlparameter}">log</a></li> +<li class="active">tags</li> +</ul> +</div> + +<div class="main"> +<h2>{repo|escape}</h2> +<h3>tags</h3> + +<form class="search" action="{url}log"> +{sessionvars%hiddenformentry} +<p><input name="rev" id="search1" type="text" size="30"></p> +</form> + +<table class="bigtable"> +<tr> + <th>tag</th> + <th>node</th> +</tr> +{entries%tagentry} +</table> +</div> + +{footer}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/static/style-coal.css Tue Apr 01 08:34:23 2008 +0200 @@ -0,0 +1,163 @@ +body { + margin: 0; + padding: 0; + background: black url(background.png) repeat-x; + font-family: sans; +} + +.main { + position: absolute; + margin-top: 0; + background: white; + padding: 2em; + border-right: 15px solid black; + border-bottom: 15px solid black; + margin-right: 150px; +} + +.overflow { + width: 100%; + overflow: auto; +} + +.main { + background: white; +} + +.menu { + background: #999; + padding: 10px; + width: 75px; + margin: 0; + font-size: 80% /*smaller*/; + text-align: left; + position: fixed; + top: 27px; + left: auto; + right: 27px; +} + +.menu ul { + list-style: none; + padding: 0; + margin: 10px 0 0 0; +} + +.menu li { + margin-bottom: 3px; + padding: 2px 4px; + background: white; + color: black; + font-weight: normal; +} + +.menu li.active { + border-left: 3px solid black; +} + +.search { + position: absolute; + top: .7em; + right: 2em; +} + +.menu a { color: black; } + +a { text-decoration:none; } +.age { white-space:nowrap; } +.date { white-space:nowrap; } +.indexlinks { white-space:nowrap; } +.parity0 { background-color: #f5f5f5; } +.parity1 { background-color: white; } +.plusline { color: green; } +.minusline { color: red; } +.atline { color: purple; } + +.navigate { + text-align: right; + font-size: 60%; + margin: 1em 0 1em 0; +} + +.tag { + color: #999; + font-size: 70%; + font-weight: normal; + margin-left: .5em; + vertical-align: text-baseline; +} + +.navigate a { + padding: 2pt; + background-color: #f5f5f5; + color: black; +} + +/* Common */ +pre { margin: 0; } + +h2 { font-size: 120%; border-bottom: 1px solid #999; } +h3 { + margin-top: -.7em; + font-size: 100%; +} + +/* log and tags tables */ +.bigtable { + border-bottom: 1px solid #999; + border-collapse: collapse; + font-size: 90%; + width: 100%; + font-weight: normal; + text-align: left; +} + +.bigtable td { + padding: 1px 4px 1px 4px; + vertical-align: top; +} + +.bigtable th { + padding: 1px 4px 1px 4px; + border-bottom: 1px solid #999; + font-size: smaller; +} +.bigtable tr { border: none; } +.bigtable .age { width: 6em; } +.bigtable .author { width: 12em; } +.bigtable .description { } +.bigtable .node { width: 5em; font-family: monospace;} +.bigtable .lineno { width: 2em; text-align: right;} +.bigtable .lineno a { color: #999; font-size: smaller; font-family: monospace;} +.bigtable td.source { font-family: monospace; white-space: pre; } +.bigtable .permissions { width: 4em; } +.bigtable td.permissions { font-family: monospace; } +.bigtable .date { width: 10em; } +.bigtable .size { width: 5em; text-align: right; } +.bigtable td.size { font-family: monospace; } +.bigtable .annotate { text-align: right; padding-right: } +.bigtable td.annotate { font-size: smaller; } + +/* Changeset entry */ +#changesetEntry { + border-collapse: collapse; + font-size: 90%; + width: 100%; + margin-bottom: 1em; +} + +#changesetEntry th { + padding: 1px 4px 1px 4px; + width: 4em; + text-align: right; + font-weight: normal; + color: #999; + margin-right: .5em; + vertical-align: top; +} + +div.description { + border-left: 3px solid #999; + margin: 1em 0 1em 0; + padding: .3em; +}
--- a/tests/test-serve.out Tue Apr 01 08:33:17 2008 +0200 +++ b/tests/test-serve.out Tue Apr 01 08:34:23 2008 +0200 @@ -1,12 +1,12 @@ % Without -v access log created - .hg/hgrc respected % With -v -listening at http://localhost/ (127.0.0.1) +listening at http://localhost/ (bound to 127.0.0.1) % With --prefix foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1)