hgweb: allow urls to be shorter by using shortcuts
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Tue, 18 Oct 2005 20:06:34 -0700
changeset 1406 34cb3957d875
parent 1405 6fd6527f95eb
child 1407 db571bcaa35d
hgweb: allow urls to be shorter by using shortcuts for example cs=xxx will be expanded to cmd=changeset;node=xxx
mercurial/hgweb.py
--- 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", "")