# HG changeset patch # User Josef "Jeff" Sipek # Date 1133775047 18000 # Node ID 385b8872b8e31729a6689fff61600eeeb1845176 # Parent 1d7d0c07e8f38005e779adb41eda042251c0c40c [hgweb] Initial import of the "gitweb" style diff --git a/mercurial/hgweb.py b/mercurial/hgweb.py --- a/mercurial/hgweb.py +++ b/mercurial/hgweb.py @@ -632,6 +632,7 @@ class hgweb(object): for k,n in i: yield {"parity": parity, "tag": k, + "date": cl.read(n)[2], "node": hex(n)} parity = 1 - parity @@ -639,6 +640,76 @@ class hgweb(object): manifest=hex(mf), entries=entries) + def summary(self): + cl = self.repo.changelog + mf = cl.read(cl.tip())[0] + + i = self.repo.tagslist() + i.reverse() + + def tagentries(**map): + parity = 0 + count = 0 + for k,n in i: + if k == "tip": # skip tip + continue; + + count += 1 + if count > 10: # limit to 10 tags + break; + + c = cl.read(n) + m = c[0] + t = c[2] + + yield self.t("tagentry", + parity = parity, + tag = k, + node = hex(n), + date = t, + manifest = hex(m)) + parity = 1 - parity + + def changelist(**map): + parity = 0 + cl = self.repo.changelog + l = [] # build a list in forward order for efficiency + for i in range(start, end): + n = cl.node(i) + changes = cl.read(n) + hn = hex(n) + t = changes[2] + + l.insert(0, self.t( + 'shortlogentry', + parity = parity, + author = changes[1], + manifest = hex(changes[0]), + desc = changes[4], + date = t, + rev = i, + node = hn)) + parity = 1 - parity + + yield l + + cl = self.repo.changelog + mf = cl.read(cl.tip())[0] + count = cl.count() + start = max(0, count - self.maxchanges) + end = min(count, start + self.maxchanges) + pos = end - 1 + + yield self.t("summary", + desc = self.repo.ui.config("web", "description", "unknown"), + owner = (self.repo.ui.config("ui", "username") or # preferred + self.repo.ui.config("web", "contact") or # deprecated + self.repo.ui.config("web", "author", "unknown")), # also + lastchange = (0, 0), # FIXME + manifest = hex(mf), + tags = tagentries, + shortlog = changelist) + def filediff(self, file, changeset): cl = self.repo.changelog n = self.repo.lookup(changeset) @@ -798,6 +869,9 @@ class hgweb(object): elif req.form['cmd'][0] == 'tags': req.write(self.tags()) + elif req.form['cmd'][0] == 'summary': + req.write(self.summary()) + elif req.form['cmd'][0] == 'filediff': req.write(self.filediff(req.form['file'][0], req.form['node'][0])) diff --git a/templates/changelog-gitweb.tmpl b/templates/changelog-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/changelog-gitweb.tmpl @@ -0,0 +1,30 @@ +#header# +#repo|escape#: Changelog + + + + + + +
+ +
+ + + + +#entries%changelogentry# + +#footer# diff --git a/templates/changelogentry-gitweb.tmpl b/templates/changelogentry-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/changelogentry-gitweb.tmpl @@ -0,0 +1,14 @@ +
+#date|age# ago#desc|firstline|escape# +
+
+ +#author|obfuscate# [#date|rfc822date#]
+
+
+#desc|addbreaks# +
+
+
diff --git a/templates/changeset-gitweb.tmpl b/templates/changeset-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/changeset-gitweb.tmpl @@ -0,0 +1,40 @@ +#header# +#repo|escape#: Changeset + + + + + + + + +
+#desc|escape|firstline# +
+
+ + + + + +#parent%changesetparent# +#changesettag# +
author#author|obfuscate#
#date|date# (#date|age# ago)
changeset#node|short#
manifest#manifest|short#
+ +
+#desc|addbreaks# +
+ +
+ +#files# +
+ +
#diff#
+ +#footer# diff --git a/templates/error-gitweb.tmpl b/templates/error-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/error-gitweb.tmpl @@ -0,0 +1,12 @@ +#header# + + +
+
+Error parsing query string
+
+
+ +#footer# diff --git a/templates/fileannotate-gitweb.tmpl b/templates/fileannotate-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/fileannotate-gitweb.tmpl @@ -0,0 +1,43 @@ +#header# +#repo|escape#: Annotate + + + + + + + + +

Annotate #file# (#filenode|short#)

+ + + + + +#parent%fileannotateparent# + + + + + + + + + + + + +
changeset #rev#:#node|short#
manifest:#manifest|short#
author:#author|obfuscate#
date:#date|date# (#date|age# ago)
permissions:#permissions|permissions#
+ +
+ + +#annotate%annotateline# +
+ +#footer# diff --git a/templates/filelog-gitweb.tmpl b/templates/filelog-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/filelog-gitweb.tmpl @@ -0,0 +1,9 @@ +#header# + + + +#entries# + +#footer# diff --git a/templates/filerevision-gitweb.tmpl b/templates/filerevision-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/filerevision-gitweb.tmpl @@ -0,0 +1,22 @@ +#header# +#repo|escape#: File revision + + + + + + + + +
#desc|firstline|escape#
+
#file#
+
+#text# +
+ +#footer# diff --git a/templates/footer-gitweb.tmpl b/templates/footer-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/footer-gitweb.tmpl @@ -0,0 +1,6 @@ + + + diff --git a/templates/header-gitweb.tmpl b/templates/header-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/header-gitweb.tmpl @@ -0,0 +1,59 @@ +Content-type: text/html + + + + + + + + + diff --git a/templates/manifest-gitweb.tmpl b/templates/manifest-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/manifest-gitweb.tmpl @@ -0,0 +1,27 @@ +#header# +#repo|escape#: Manifest + + + + + + + + +
#path|escape#
+
+ + + + + + +#dentries%manifestdirentry# +#fentries%manifestfileentry# +
drwxr-xr-x[up]
+#footer# diff --git a/templates/map-gitweb b/templates/map-gitweb new file mode 100644 --- /dev/null +++ b/templates/map-gitweb @@ -0,0 +1,42 @@ +default = "summary" +header = header-gitweb.tmpl +footer = footer-gitweb.tmpl +search = search-gitweb.tmpl +changelog = changelog-gitweb.tmpl +summary = summary-gitweb.tmpl +error = error-gitweb.tmpl +naventry = "#label# " +navshortentry = "#label# " +filedifflink = "#file# " +filenodelink = "#file#file | diff | revisions" +fileellipses = "..." +changelogentry = changelogentry-gitweb.tmpl +searchentry = changelogentry-gitweb.tmpl +changeset = changeset-gitweb.tmpl +manifest = manifest-gitweb.tmpl +manifestdirentry = "drwxr-xr-x#basename#/manifest" +manifestfileentry = "#permissions|permissions##basename#file | revisions | annotate" +filerevision = filerevision-gitweb.tmpl +fileannotate = fileannotate-gitweb.tmpl +filediff = filediff-gitweb.tmpl +filelog = filelog-gitweb.tmpl +fileline = "
#linenumber# #line|escape#
" +filelogentry = filelogentry-gitweb.tmpl +annotateline = "#author|obfuscate#@#rev#
#line|escape#
" +difflineplus = "
#line|escape#
" +difflineminus = "
#line|escape#
" +difflineat = "
#line|escape#
" +diffline = "
#line|escape#
" +changelogparent = "parent #rev#:#node|short#" +changesetparent = "parent#node|short#" +filerevparent = "parent:#node|short#" +fileannotateparent = "parent:#node|short#" +tags = tags-gitweb.tmpl +tagentry = "#date|age# ago#tag#changeset | changelog | manifest" +diffblock = "#lines#" +changelogtag = "tag:#tag#" +changesettag = "tag#tag#" +filediffparent = "parent #rev#:#node|short#" +filelogparent = "parent #rev#: #node|short#" +shortlog = shortlog-gitweb.tmpl +shortlogentry = "#date|age# ago#desc|firstline|escape#changeset | manifest" diff --git a/templates/search-gitweb.tmpl b/templates/search-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/search-gitweb.tmpl @@ -0,0 +1,24 @@ +#header# + + +

searching for #query|escape#

+ +
+search: + + + +
+ +#entries# + +
+search: + + + +
+ +#footer# diff --git a/templates/shortlog-gitweb.tmpl b/templates/shortlog-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/shortlog-gitweb.tmpl @@ -0,0 +1,13 @@ +#header# + + + + +#entries# +
+ +#footer# diff --git a/templates/summary-gitweb.tmpl b/templates/summary-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/summary-gitweb.tmpl @@ -0,0 +1,34 @@ +#header# +#repo|escape#: Summary + + + + + + + +
 
+ + + + +
description#desc#
owner#owner#
+ +
changes
+ +#shortlog# + +
...
+ +
tags
+ +#tags# + +
...
+ +#footer# diff --git a/templates/tags-gitweb.tmpl b/templates/tags-gitweb.tmpl new file mode 100644 --- /dev/null +++ b/templates/tags-gitweb.tmpl @@ -0,0 +1,21 @@ +#header# +#repo|escape#: Tags + + + + + + + + + +#entries%tagentry# +
+ +#footer#