# HG changeset patch # User Robert Bachmann # Date 1188484937 -7200 # Node ID 46c5e1ee8aaabf542cfeed435953f68dd65733f8 # Parent 980da86fc66abd81a960ae8396c8905a4cdaef23 Added support for the Atom syndication format diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -206,7 +206,7 @@ class hgweb(object): opts=diffopts), f, tn) def changelog(self, ctx, shortlog=False): - def changelist(**map): + def changelist(limit=0,**map): cl = self.repo.changelog l = [] # build a list in forward order for efficiency for i in xrange(start, end): @@ -226,6 +226,9 @@ class hgweb(object): "tags": self.nodetagsdict(n), "branches": self.nodebranchdict(ctx)}) + if limit > 0: + l = l[:limit] + for e in l: yield e @@ -243,7 +246,9 @@ class hgweb(object): yield self.t(shortlog and 'shortlog' or 'changelog', changenav=changenav, node=hex(cl.tip()), - rev=pos, changesets=count, entries=changelist, + 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, query): @@ -344,7 +349,7 @@ class hgweb(object): pos = end - 1 parity = paritygen(self.stripecount, offset=start-end) - def entries(**map): + def entries(limit=0, **map): l = [] for i in xrange(start, end): @@ -362,13 +367,17 @@ class hgweb(object): "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) yield self.t("filelog", file=f, node=hex(fctx.node()), nav=nav, - entries=entries) + entries=lambda **x: entries(limit=0, **x), + latestentry=lambda **x: entries(limit=1, **x)) def filerevision(self, fctx): f = fctx.path() @@ -508,10 +517,14 @@ class hgweb(object): i.reverse() parity = paritygen(self.stripecount) - def entries(notip=False, **map): + 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(), @@ -519,8 +532,9 @@ class hgweb(object): yield self.t("tags", node=hex(self.repo.changelog.tip()), - entries=lambda **x: entries(False, **x), - entriesnotip=lambda **x: entries(True, **x)) + entries=lambda **x: entries(False,0, **x), + entriesnotip=lambda **x: entries(True,0, **x), + latestentry=lambda **x: entries(True,1, **x)) def summary(self): i = self.repo.tagslist() diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -270,6 +270,7 @@ common_filters = { "permissions": permissions, "person": person, "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), + "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), "short": lambda x: x[:12], "shortdate": shortdate, "stringify": stringify, diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1448,7 +1448,7 @@ def makedate(): tz = time.timezone return time.mktime(lt), tz -def datestr(date=None, format='%a %b %d %H:%M:%S %Y', timezone=True): +def datestr(date=None, format='%a %b %d %H:%M:%S %Y', timezone=True, timezone_format=" %+03d%02d"): """represent a (unixtime, offset) tuple as a localized time. unixtime is seconds since the epoch, and offset is the time zone's number of seconds away from UTC. if timezone is false, do not @@ -1456,7 +1456,7 @@ def datestr(date=None, format='%a %b %d t, tz = date or makedate() s = time.strftime(format, time.gmtime(float(t) - tz)) if timezone: - s += " %+03d%02d" % (-tz / 3600, ((-tz % 3600) / 60)) + s += timezone_format % (-tz / 3600, ((-tz % 3600) / 60)) return s def strdate(string, format, defaults): diff --git a/templates/atom/changelog.tmpl b/templates/atom/changelog.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/changelog.tmpl @@ -0,0 +1,10 @@ +#header# + + {urlbase}{url} + + + #repo|escape# Changelog + #latestentry%feedupdated# + +#entries%changelogentry# + diff --git a/templates/atom/changelogentry.tmpl b/templates/atom/changelogentry.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/changelogentry.tmpl @@ -0,0 +1,16 @@ + + #desc|strip|firstline|strip|escape# + http://www.selenic.com/mercurial/#changeset-{node} + + + #author|person|escape# + #author|email|obfuscate# + + #date|rfc3339date# + #date|rfc3339date# + + + #desc|escape# + + + diff --git a/templates/atom/filelog.tmpl b/templates/atom/filelog.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/filelog.tmpl @@ -0,0 +1,8 @@ +#header# + {urlbase}{url}atom-log/tip/{file|escape} + + #repo|escape#: #file|escape# history + #latestentry%feedupdated# + +#entries%changelogentry# + diff --git a/templates/atom/header.tmpl b/templates/atom/header.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/header.tmpl @@ -0,0 +1,4 @@ +Content-type: application/atom+xml; charset={encoding} + + + \ No newline at end of file diff --git a/templates/atom/map b/templates/atom/map new file mode 100644 --- /dev/null +++ b/templates/atom/map @@ -0,0 +1,9 @@ +default = 'changelog' +feedupdated = '#date|rfc3339date#' +header = header.tmpl +changelog = changelog.tmpl +changelogentry = changelogentry.tmpl +filelog = filelog.tmpl +filelogentry = filelogentry.tmpl +tags = tags.tmpl +tagentry = tagentry.tmpl diff --git a/templates/atom/tagentry.tmpl b/templates/atom/tagentry.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/tagentry.tmpl @@ -0,0 +1,8 @@ + + #tag|escape# + + http://www.selenic.com/mercurial/#tag-{node} + #date|rfc3339date# + #date|rfc3339date# + #tag|strip|escape# + diff --git a/templates/atom/tags.tmpl b/templates/atom/tags.tmpl new file mode 100644 --- /dev/null +++ b/templates/atom/tags.tmpl @@ -0,0 +1,11 @@ +#header# + {urlbase}{url} + + + #repo|escape#: tags + #repo|escape# tag history + Mercurial SCM + #latestentry%feedupdated# + +#entriesnotip%tagentry# + diff --git a/templates/changelog.tmpl b/templates/changelog.tmpl --- a/templates/changelog.tmpl +++ b/templates/changelog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: changelog + @@ -11,6 +13,7 @@ manifest #archives%archiveentry# rss +atom

changelog for #repo|escape#

diff --git a/templates/filelog.tmpl b/templates/filelog.tmpl --- a/templates/filelog.tmpl +++ b/templates/filelog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: #file|escape# history + @@ -13,6 +15,7 @@ file annotate rss +atom

#file|escape# revision history

diff --git a/templates/gitweb/changelog.tmpl b/templates/gitweb/changelog.tmpl --- a/templates/gitweb/changelog.tmpl +++ b/templates/gitweb/changelog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Changelog + diff --git a/templates/gitweb/changeset.tmpl b/templates/gitweb/changeset.tmpl --- a/templates/gitweb/changeset.tmpl +++ b/templates/gitweb/changeset.tmpl @@ -1,5 +1,7 @@ #header# {repo|escape}: changeset {rev}:{node|short} + diff --git a/templates/gitweb/error.tmpl b/templates/gitweb/error.tmpl --- a/templates/gitweb/error.tmpl +++ b/templates/gitweb/error.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Error + diff --git a/templates/gitweb/fileannotate.tmpl b/templates/gitweb/fileannotate.tmpl --- a/templates/gitweb/fileannotate.tmpl +++ b/templates/gitweb/fileannotate.tmpl @@ -1,5 +1,7 @@ #header# {repo|escape}: {file|escape}@{node|short} (annotated) + diff --git a/templates/gitweb/filediff.tmpl b/templates/gitweb/filediff.tmpl --- a/templates/gitweb/filediff.tmpl +++ b/templates/gitweb/filediff.tmpl @@ -1,5 +1,7 @@ {header} {repo|escape}: diff {file|escape} + diff --git a/templates/gitweb/filelog.tmpl b/templates/gitweb/filelog.tmpl --- a/templates/gitweb/filelog.tmpl +++ b/templates/gitweb/filelog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: File revisions + diff --git a/templates/gitweb/filerevision.tmpl b/templates/gitweb/filerevision.tmpl --- a/templates/gitweb/filerevision.tmpl +++ b/templates/gitweb/filerevision.tmpl @@ -1,5 +1,7 @@ #header# {repo|escape}: {file|escape}@{node|short} + diff --git a/templates/gitweb/footer.tmpl b/templates/gitweb/footer.tmpl --- a/templates/gitweb/footer.tmpl +++ b/templates/gitweb/footer.tmpl @@ -1,6 +1,7 @@ diff --git a/templates/gitweb/index.tmpl b/templates/gitweb/index.tmpl --- a/templates/gitweb/index.tmpl +++ b/templates/gitweb/index.tmpl @@ -14,6 +14,7 @@ Contact Last change   +   #entries%indexentry# diff --git a/templates/gitweb/manifest.tmpl b/templates/gitweb/manifest.tmpl --- a/templates/gitweb/manifest.tmpl +++ b/templates/gitweb/manifest.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Manifest + diff --git a/templates/gitweb/map b/templates/gitweb/map --- a/templates/gitweb/map +++ b/templates/gitweb/map @@ -52,7 +52,7 @@ branchtag = '#repo|escape#: Search + diff --git a/templates/gitweb/shortlog.tmpl b/templates/gitweb/shortlog.tmpl --- a/templates/gitweb/shortlog.tmpl +++ b/templates/gitweb/shortlog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Shortlog + diff --git a/templates/gitweb/summary.tmpl b/templates/gitweb/summary.tmpl --- a/templates/gitweb/summary.tmpl +++ b/templates/gitweb/summary.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Summary + diff --git a/templates/gitweb/tags.tmpl b/templates/gitweb/tags.tmpl --- a/templates/gitweb/tags.tmpl +++ b/templates/gitweb/tags.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: Tags + diff --git a/templates/map b/templates/map --- a/templates/map +++ b/templates/map @@ -47,7 +47,7 @@ filediffparent = '#repo|escape#: changelog + @@ -11,6 +13,7 @@ manifest #archives%archiveentry# rss +atom

changelog for #repo|escape#

diff --git a/templates/old/filelog.tmpl b/templates/old/filelog.tmpl --- a/templates/old/filelog.tmpl +++ b/templates/old/filelog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: #file|escape# history + @@ -13,6 +15,7 @@ file annotate rss +atom

#file|escape# revision history

diff --git a/templates/old/map b/templates/old/map --- a/templates/old/map +++ b/templates/old/map @@ -46,7 +46,7 @@ filediffparent = '#repo|escape#: shortlog + @@ -11,6 +13,7 @@ manifest #archives%archiveentry# rss +atom

shortlog for #repo|escape#

diff --git a/templates/old/tags.tmpl b/templates/old/tags.tmpl --- a/templates/old/tags.tmpl +++ b/templates/old/tags.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: tags + @@ -10,6 +12,7 @@ shortlog manifest rss +atom

tags:

diff --git a/templates/shortlog.tmpl b/templates/shortlog.tmpl --- a/templates/shortlog.tmpl +++ b/templates/shortlog.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: shortlog + @@ -11,6 +13,7 @@ manifest #archives%archiveentry# rss +atom

shortlog for #repo|escape#

diff --git a/templates/tags.tmpl b/templates/tags.tmpl --- a/templates/tags.tmpl +++ b/templates/tags.tmpl @@ -1,5 +1,7 @@ #header# #repo|escape#: tags + @@ -10,6 +12,7 @@ shortlog manifest rss +atom

tags: