# HG changeset patch # User Matt Mackall # Date 1134619938 21600 # Node ID 4737b36e324ee3e9c030d3c3de473dd1f01dfdb9 # Parent bcdc030c59f8956ce0ed4f893014771b61a7fca2# Parent 85803ec2daab5c97c7f871af01158652a5db7bb3 Merge http://sh0n.net/jeffpc/repos/hg-gitweb/ diff --git a/mercurial/hgweb.py b/mercurial/hgweb.py --- a/mercurial/hgweb.py +++ b/mercurial/hgweb.py @@ -632,6 +632,8 @@ class hgweb(object): for k,n in i: yield {"parity": parity, "tag": k, + "tagmanifest": hex(cl.read(n)[0]), + "date": cl.read(n)[2], "node": hex(n)} parity = 1 - parity @@ -639,6 +641,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, + tagmanifest = 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 +870,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 + + + + + + + + +
#file#
+ + + + + +#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,20 @@ +#header# +#repo|escape#: Manifest + + + + + + + + + +#entries%filelogentry# +
+ +#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,41 @@ +#header# +#repo|escape#: File revision + + + + + + + + +
#file#
+ + + + + +#parent%fileannotateparent# + + + + + + + + + + + + +
changeset #rev#:#node|short#
manifest:#manifest|short#
author:#author|obfuscate#
date:#date|date# (#date|age# ago)
permissions:#permissions|permissions#
+ +
+#text%fileline# +
+ +#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 | 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 +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" +filelogentry = "#date|age# ago#desc|firstline|escape# annotate" 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#