Mercurial > hg
changeset 980:5197fb9d65d5
Merge with MPM
author | Josef "Jeff" Sipek <jeffpc@optonline.net> |
---|---|
date | Wed, 17 Aug 2005 22:59:47 -0500 |
parents | 87d40e085e08 (diff) 1300271ba8de (current diff) |
children | 4f81068ed8cd |
files | doc/hg.1.txt mercurial/commands.py mercurial/hgweb.py templates/changelog.tmpl templates/fileannotate.tmpl templates/filelog.tmpl templates/filerevision.tmpl templates/manifest.tmpl templates/tags.tmpl |
diffstat | 7 files changed, 103 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb.py Wed Aug 17 18:52:27 2005 -0800 +++ b/mercurial/hgweb.py Wed Aug 17 22:59:47 2005 -0500 @@ -64,25 +64,6 @@ else: sys.stdout.write(str(thing)) -def template(tmpl, filters = {}, **map): - while tmpl: - m = re.search(r"#([a-zA-Z0-9]+)((\|[a-zA-Z0-9]+)*)#", tmpl) - if m: - yield tmpl[:m.start(0)] - v = map.get(m.group(1), "") - v = callable(v) and v(**map) or v - - fl = m.group(2) - if fl: - for f in fl.split("|")[1:]: - v = filters[f](v) - - yield v - tmpl = tmpl[m.end(0):] - else: - yield tmpl - return - class templater: def __init__(self, mapfile, filters = {}, defaults = {}): self.cache = {} @@ -109,7 +90,37 @@ tmpl = self.cache[t] except KeyError: tmpl = self.cache[t] = file(self.map[t]).read() - return template(tmpl, self.filters, **m) + return self.template(tmpl, self.filters, **m) + + def template(self, tmpl, filters = {}, **map): + while tmpl: + m = re.search(r"#([a-zA-Z0-9]+)((%[a-zA-Z0-9]+)*)((\|[a-zA-Z0-9]+)*)#", tmpl) + if m: + yield tmpl[:m.start(0)] + v = map.get(m.group(1), "") + v = callable(v) and v(**map) or v + + format = m.group(2) + fl = m.group(4) + + if format: + q = v.__iter__ + for i in q(): + lm = map.copy() + lm.update(i) + yield self(format[1:], **lm) + + v = "" + + elif fl: + for f in fl.split("|")[1:]: + v = filters[f](v) + + yield v + tmpl = tmpl[m.end(0):] + else: + yield tmpl + return def rfc822date(x): return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(x)) @@ -241,12 +252,12 @@ if pos + f < count: l.append(("+" + r, pos + f)) if pos - f >= 0: l.insert(0, ("-" + r, pos - f)) - yield self.t("naventry", rev = 0, label="(0)") + yield {"rev": 0, "label": "(0)"} for label, rev in l: - yield self.t("naventry", label = label, rev = rev) + yield {"label": label, "rev": rev} - yield self.t("naventry", label="tip") + yield {"label": "tip", "rev": ""} def changelist(**map): parity = (start - end) & 1 @@ -258,22 +269,21 @@ hn = hex(n) t = float(changes[2].split(' ')[0]) - l.insert(0, self.t( - 'changelogentry', - parity = parity, - author = changes[1], - parent = self.parents("changelogparent", + l.insert(0, { + "parity": parity, + "author": changes[1], + "parent": self.parents("changelogparent", cl.parents(n), cl.rev), - changelogtag = self.showtag("changelogtag",n), - manifest = hex(changes[0]), - desc = changes[4], - date = t, - files = self.listfilediffs(changes[3], n), - rev = i, - node = hn)) + "changelogtag": self.showtag("changelogtag",n), + "manifest": hex(changes[0]), + "desc": changes[4], + "date": t, + "files": self.listfilediffs(changes[3], n), + "rev": i, + "node": hn}) parity = 1 - parity - yield l + for e in l: yield e cl = self.repo.changelog mf = cl.read(cl.tip())[0] @@ -388,20 +398,19 @@ cs = cl.read(cl.node(lr)) t = float(cs[2].split(' ')[0]) - l.insert(0, self.t("filelogentry", - parity = parity, - filenode = hex(n), - filerev = i, - file = f, - node = hex(cn), - author = cs[1], - date = t, - parent = self.parents("filelogparent", + l.insert(0, {"parity": parity, + "filenode": hex(n), + "filerev": i, + "file": f, + "node": hex(cn), + "author": cs[1], + "date": t, + "parent": self.parents("filelogparent", fl.parents(n), fl.rev, file=f), - desc = cs[4])) + "desc": cs[4]}) parity = 1 - parity - yield l + for e in l: yield e yield self.t("filelog", file = f, @@ -421,9 +430,9 @@ def lines(): for l, t in enumerate(text.splitlines(1)): - yield self.t("fileline", line = t, - linenumber = "% 6d" % (l + 1), - parity = l & 1) + yield {"line": t, + "linenumber": "% 6d" % (l + 1), + "parity": l & 1} yield self.t("filerevision", file = f, filenode = node, @@ -477,13 +486,12 @@ parity = 1 - parity last = cnode - yield self.t("annotateline", - parity = parity, - node = hex(cnode), - rev = r, - author = name, - file = f, - line = l) + yield {"parity": parity, + "node": hex(cnode), + "rev": r, + "author": name, + "file": f, + "line": l} yield self.t("fileannotate", file = f, @@ -527,28 +535,40 @@ fl.sort() for f in fl: full, fnode = files[f] - if fnode: - yield self.t("manifestfileentry", - file = full, - manifest = mnode, - filenode = hex(fnode), - parity = parity, - basename = f, - permissions = mff[full]) - else: - yield self.t("manifestdirentry", - parity = parity, - path = os.path.join(path, f), - manifest = mnode, basename = f[:-1]) + if not fnode: + continue + + yield {"file": full, + "manifest": mnode, + "filenode": hex(fnode), + "parity": parity, + "basename": f, + "permissions": mff[full]} parity = 1 - parity + def dirlist(**map): + parity = 0 + fl = files.keys() + fl.sort() + for f in fl: + full, fnode = files[f] + if fnode: + continue + + yield {"parity": parity, + "path": os.path.join(path, f), + "manifest": mnode, + "basename": f[:-1]} + parity = 1 - parity + yield self.t("manifest", manifest = mnode, rev = rev, node = hex(node), path = path, up = up(path), - entries = filelist) + fentries = filelist, + dentries = dirlist) def tags(self): cl = self.repo.changelog @@ -560,10 +580,9 @@ def entries(**map): parity = 0 for k,n in i: - yield self.t("tagentry", - parity = parity, - tag = k, - node = hex(n)) + yield {"parity": parity, + "tag": k, + "node": hex(n)} parity = 1 - parity yield self.t("tags",
--- a/templates/changelog.tmpl Wed Aug 17 18:52:27 2005 -0800 +++ b/templates/changelog.tmpl Wed Aug 17 22:59:47 2005 -0500 @@ -18,18 +18,18 @@ <label for="search1">search:</label> <input type="hidden" name="cmd" value="changelog"> <input name="rev" id="search1" type="text" size="30"> -navigate: <small>#changenav#</small> +navigate: <small>#changenav%naventry#</small> </p> </form> -#entries# +#entries%changelogentry# <form action="#"> <p> <label for="search2">search:</label> <input type="hidden" name="cmd" value="changelog"> <input name="rev" id="search2" type="text" size="30"> -navigate: <small>#changenav#</small> +navigate: <small>#changenav%naventry#</small> </p> </form>
--- a/templates/fileannotate.tmpl Wed Aug 17 18:52:27 2005 -0800 +++ b/templates/fileannotate.tmpl Wed Aug 17 22:59:47 2005 -0500 @@ -36,7 +36,7 @@ <br/> <table cellspacing="0" cellpadding="0"> -#annotate# +#annotate%annotateline# </table> #footer#
--- a/templates/filelog.tmpl Wed Aug 17 18:52:27 2005 -0800 +++ b/templates/filelog.tmpl Wed Aug 17 22:59:47 2005 -0500 @@ -16,6 +16,6 @@ <h2>#file# revision history</h2> -#entries# +#entries%filelogentry# #footer#
--- a/templates/filerevision.tmpl Wed Aug 17 18:52:27 2005 -0800 +++ b/templates/filerevision.tmpl Wed Aug 17 22:59:47 2005 -0500 @@ -35,7 +35,7 @@ </table> <pre> -#text# +#text%fileline# </pre> #footer#
--- a/templates/manifest.tmpl Wed Aug 17 18:52:27 2005 -0800 +++ b/templates/manifest.tmpl Wed Aug 17 22:59:47 2005 -0500 @@ -15,6 +15,7 @@ <tr class="parity1"> <td><tt>drwxr-xr-x</tt> <td><a href="?cmd=manifest;manifest=#manifest#;path=#up#">[up]</a> -#entries# +#dentries%manifestdirentry# +#fentries%manifestfileentry# </table> #footer#