[PATCH 5 of 6] Use a template for the error message
Matt Mackall
mpm at selenic.com
Wed Aug 24 17:53:38 CDT 2005
On Wed, Aug 24, 2005 at 05:47:27PM +0200, Ollivier Robert wrote:
> Patch subject is complete summary.
>
>
> # HG changeset patch
> # User Ollivier Robert <roberto at keltia.freenix.fr>
> # Node ID 5e98a58ace70cc38ae1211b57f41678f453fd4b7
> # Parent 05f2e370f11340ce10135b35cccf8180be8ecde0
> Use a template for the error message.
Bad practice to mix code movement with substantive changes. This patch
is probably only a single line, but not obviously so.
> diff -r 05f2e370f113 -r 5e98a58ace70 mercurial/hgweb.py
> --- a/mercurial/hgweb.py Wed Aug 24 14:24:32 2005
> +++ b/mercurial/hgweb.py Wed Aug 24 14:57:00 2005
> @@ -55,10 +55,6 @@
>
> def httphdr(type):
> sys.stdout.write('Content-type: %s\n\n' % type)
> -
> -def httpnotfound(filename):
> - sys.stdout.write("Status: 404\r\n\r\n")
> - sys.stdout.write("File not found: (%s)" % (filename, ))
>
> def write(*things):
> for thing in things:
> @@ -843,6 +839,44 @@
> self.cp.read(config)
>
> def run(self):
> + def header(**map):
> + yield tmpl("header", **map)
> +
> + def footer(**map):
> + yield tmpl("footer", **map)
> +
> + templates = templatepath()
> + m = os.path.join(templates, "map")
> + tmpl = templater(m, common_filters,
> + {"header": header, "footer": footer})
> +
> + def entries(**map):
> + parity = 0
> + l = self.cp.items("paths")
> + l.sort()
> + for v,r in l:
> + cp2 = ConfigParser.SafeConfigParser()
> + cp2.read(os.path.join(r, ".hg", "hgrc"))
> +
> + def get(sec, val, default):
> + try:
> + return cp2.get(sec, val)
> + except:
> + return default
> +
> + url = os.environ["REQUEST_URI"] + "/" + v
> + url = url.replace("//", "/")
> +
> + yield dict(author = get("web", "author", "unknown"),
> + name = get("web", "name", v),
> + url = url,
> + parity = parity,
> + shortdesc = get("web", "description", "unknown"),
> + lastupdate = os.stat(os.path.join(r, ".hg",
> + "00changelog.d")).st_mtime)
> +
> + parity = 1 - parity
> +
> try:
> virtual = os.environ["PATH_INFO"]
> except:
> @@ -857,45 +891,7 @@
> h.run()
> return
> else:
> - httpnotfound(virtual)
> + write(tmpl("notfound", repo = virtual))
> return
>
> - def header(**map):
> - yield tmpl("header", **map)
> -
> - def footer(**map):
> - yield tmpl("footer", **map)
> -
> - templates = templatepath()
> - m = os.path.join(templates, "map")
> - tmpl = templater(m, common_filters,
> - {"header": header, "footer": footer})
> -
> - def entries(**map):
> - parity = 0
> - l = self.cp.items("paths")
> - l.sort()
> - for v,r in l:
> - cp2 = ConfigParser.SafeConfigParser()
> - cp2.read(os.path.join(r, ".hg", "hgrc"))
> -
> - def get(sec, val, default):
> - try:
> - return cp2.get(sec, val)
> - except:
> - return default
> -
> - url = os.environ["REQUEST_URI"] + "/" + v
> - url = url.replace("//", "/")
> -
> - yield dict(author = get("web", "author", "unknown"),
> - name = get("web", "name", v),
> - url = url,
> - parity = parity,
> - shortdesc = get("web", "description", "unknown"),
> - lastupdate = os.stat(os.path.join(r, ".hg",
> - "00changelog.d")).st_mtime)
> -
> - parity = 1 - parity
> -
> write(tmpl("index", entries = entries))
> diff -r 05f2e370f113 -r 5e98a58ace70 templates/map
> --- a/templates/map Wed Aug 24 14:24:32 2005
> +++ b/templates/map Wed Aug 24 14:57:00 2005
> @@ -37,3 +37,4 @@
> filelogparent = "<tr><td align="right">parent #rev#: </td><td><a href="?cmd=file;file=#file#;filenode=#node#">#node|short#</a></td></tr>"
> indexentry = "<tr class="parity#parity#"><td><a href="#url#">#name#</a></td><td>#shortdesc#</td><td>#author# <i>#email|obfuscate#</i></td><td>#lastupdate|age# ago</td></tr>"
> index = index.tmpl
> +notfound = notfound.tmpl
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list