# HG changeset patch # User Thomas Arendsen Hein # Date 1160593177 -7200 # Node ID 887da2247b577a02b0128517dc542c3dc6fa383e # Parent bc5985d533860302c7d96ebc646c0bc8725fd802 hgweb: Keep session variables (currently only style) in HTML forms, too. Adjusted default and gitweb template for this. 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 @@ -708,6 +708,16 @@ class hgweb(object): req.form['node'] = [fn[:-len(ext)]] req.form['type'] = [type_] + def sessionvars(**map): + fields = [] + if req.form.has_key('style'): + style = req.form['style'][0] + if style != self.repo.ui.config('web', 'style', ''): + fields.append(('style', style)) + + for name, value in fields: + yield dict(name=name, value=value) + def queryprefix(**map): return req.url[-1] == '?' and ';' or '?' @@ -754,6 +764,7 @@ class hgweb(object): "header": header, "footer": footer, "rawfileheader": rawfileheader, + "sessionvars": sessionvars, "queryprefix": queryprefix, "getentries": getentries }) diff --git a/templates/changelog.tmpl b/templates/changelog.tmpl --- a/templates/changelog.tmpl +++ b/templates/changelog.tmpl @@ -16,6 +16,7 @@

changelog for #repo|escape#

+{sessionvars%hiddenformentry}

@@ -26,6 +27,7 @@ navigate: #chang #entries%changelogentry# +{sessionvars%hiddenformentry}

diff --git a/templates/gitweb/changelog.tmpl b/templates/gitweb/changelog.tmpl --- a/templates/gitweb/changelog.tmpl +++ b/templates/gitweb/changelog.tmpl @@ -10,8 +10,8 @@ +{sessionvars%hiddenformentry}

diff --git a/templates/gitweb/map b/templates/gitweb/map --- a/templates/gitweb/map +++ b/templates/gitweb/map @@ -51,3 +51,4 @@ filelogentry = '#type|escape# ' indexentry = '#name|escape##description##contact|obfuscate##lastchange|age# ago #archives%archiveentry#' index = index.tmpl +hiddenformentry = '' diff --git a/templates/gitweb/search.tmpl b/templates/gitweb/search.tmpl --- a/templates/gitweb/search.tmpl +++ b/templates/gitweb/search.tmpl @@ -10,14 +10,15 @@

searching for #query|escape#

+{sessionvars%hiddenformentry} search: -
#entries#
+{sessionvars%hiddenformentry} search: diff --git a/templates/gitweb/shortlog.tmpl b/templates/gitweb/shortlog.tmpl --- a/templates/gitweb/shortlog.tmpl +++ b/templates/gitweb/shortlog.tmpl @@ -10,8 +10,8 @@ +{sessionvars%hiddenformentry}
diff --git a/templates/map b/templates/map --- a/templates/map +++ b/templates/map @@ -51,3 +51,4 @@ index = index.tmpl archiveentry = '#type|escape# ' notfound = notfound.tmpl error = error.tmpl +hiddenformentry = '' diff --git a/templates/search.tmpl b/templates/search.tmpl --- a/templates/search.tmpl +++ b/templates/search.tmpl @@ -13,6 +13,7 @@

searching for #query|escape#

+{sessionvars%hiddenformentry}

search: @@ -22,6 +23,7 @@ search: #entries# +{sessionvars%hiddenformentry}

search: diff --git a/templates/shortlog.tmpl b/templates/shortlog.tmpl --- a/templates/shortlog.tmpl +++ b/templates/shortlog.tmpl @@ -16,6 +16,7 @@

shortlog for #repo|escape#

+{sessionvars%hiddenformentry}

@@ -26,6 +27,7 @@ navigate: #chang #entries%shortlogentry# +{sessionvars%hiddenformentry}