changeset 1406:34cb3957d875

hgweb: allow urls to be shorter by using shortcuts for example cs=xxx will be expanded to cmd=changeset;node=xxx
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 18 Oct 2005 20:06:34 -0700
parents 6fd6527f95eb
children db571bcaa35d
files mercurial/hgweb.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb.py	Tue Oct 18 20:06:13 2005 -0700
+++ b/mercurial/hgweb.py	Tue Oct 18 20:06:34 2005 -0700
@@ -704,9 +704,23 @@
 
         def footer(**map):
             yield self.t("footer", **map)
+        
+        def expand_form(form):
+            shortcuts = {
+                'cs': [('cmd', ['changeset']), ('node', None)],
+            }
+            for k in shortcuts.iterkeys():
+                if form.has_key(k):
+                    for name, value in shortcuts[k]:
+                        if value is None:
+                            value = form[k]
+                        form[name] = value
+                    del form[k]
 
         self.refresh()
 
+        expand_form(req.form)
+
         t = self.repo.ui.config("web", "templates", templatepath())
         m = os.path.join(t, "map")
         style = self.repo.ui.config("web", "style", "")