# HG changeset patch # User mpm@selenic.com # Date 1124568487 25200 # Node ID 4f81068ed8cd48952eb87740d65bb8baa121a009 # Parent a51991ebf22936015e626a32e363861b1b5694be# Parent 5197fb9d65d5f858cffa91967fbc247a4b969a02 Merge with jeffpc diff -r a51991ebf229 -r 4f81068ed8cd .hgignore diff -r a51991ebf229 -r 4f81068ed8cd .hgtags diff -r a51991ebf229 -r 4f81068ed8cd MANIFEST.in diff -r a51991ebf229 -r 4f81068ed8cd README diff -r a51991ebf229 -r 4f81068ed8cd contrib/bash_completion diff -r a51991ebf229 -r 4f81068ed8cd doc/hg.1.txt diff -r a51991ebf229 -r 4f81068ed8cd doc/hgrc.5.txt diff -r a51991ebf229 -r 4f81068ed8cd mercurial/bdiff.c diff -r a51991ebf229 -r 4f81068ed8cd mercurial/commands.py diff -r a51991ebf229 -r 4f81068ed8cd mercurial/fancyopts.py diff -r a51991ebf229 -r 4f81068ed8cd mercurial/hg.py diff -r a51991ebf229 -r 4f81068ed8cd mercurial/hgweb.py --- a/mercurial/hgweb.py Sat Aug 20 11:59:10 2005 -0700 +++ b/mercurial/hgweb.py Sat Aug 20 13:08:07 2005 -0700 @@ -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)) @@ -242,12 +253,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 @@ -259,22 +270,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] @@ -389,20 +399,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, @@ -422,9 +431,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, @@ -478,13 +487,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, @@ -528,28 +536,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 @@ -561,10 +581,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", diff -r a51991ebf229 -r 4f81068ed8cd mercurial/ui.py diff -r a51991ebf229 -r 4f81068ed8cd templates/changelog.tmpl --- a/templates/changelog.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/changelog.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -18,18 +18,18 @@ -navigate: #changenav# +navigate: #changenav%naventry#

-#entries# +#entries%changelogentry#

-navigate: #changenav# +navigate: #changenav%naventry#

diff -r a51991ebf229 -r 4f81068ed8cd templates/fileannotate.tmpl --- a/templates/fileannotate.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/fileannotate.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -36,7 +36,7 @@
-#annotate# +#annotate%annotateline#
#footer# diff -r a51991ebf229 -r 4f81068ed8cd templates/filelog.tmpl --- a/templates/filelog.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/filelog.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -16,6 +16,6 @@

#file# revision history

-#entries# +#entries%filelogentry# #footer# diff -r a51991ebf229 -r 4f81068ed8cd templates/filerevision.tmpl --- a/templates/filerevision.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/filerevision.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -35,7 +35,7 @@
-#text#
+#text%fileline#
 
#footer# diff -r a51991ebf229 -r 4f81068ed8cd templates/manifest.tmpl --- a/templates/manifest.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/manifest.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -15,6 +15,7 @@ drwxr-xr-x  [up] -#entries# +#dentries%manifestdirentry# +#fentries%manifestfileentry# #footer# diff -r a51991ebf229 -r 4f81068ed8cd templates/map diff -r a51991ebf229 -r 4f81068ed8cd templates/tags.tmpl --- a/templates/tags.tmpl Sat Aug 20 11:59:10 2005 -0700 +++ b/templates/tags.tmpl Sat Aug 20 13:08:07 2005 -0700 @@ -11,7 +11,7 @@

tags:

#footer# diff -r a51991ebf229 -r 4f81068ed8cd tests/test-basic.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-copy.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-diffdir diff -r a51991ebf229 -r 4f81068ed8cd tests/test-flags.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-merge-revert2 diff -r a51991ebf229 -r 4f81068ed8cd tests/test-rawcommit1.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-tag.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-undo.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-unrelated-pull.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-up-local-change diff -r a51991ebf229 -r 4f81068ed8cd tests/test-up-local-change.out diff -r a51991ebf229 -r 4f81068ed8cd tests/test-walk.out