[PATCH] hgweb: add support for colon-separated revision format in search

Alexander Plavin me at aplavin.ru
Mon Jul 15 17:53:30 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1373830561 -14400
#      Sun Jul 14 23:36:01 2013 +0400
# Node ID 52803877038ae1a817e467fb8d49cb584b984742
# Parent  390ff286651b30b2a5f71a1901bb34aefec1c6f9
hgweb: add support for colon-separated revision format in search

Now it's possible to specify a revision in the format
<definion 1>:<definition 2>, if <definion 1> and <definition 2> point to
the same place, like in other parts of hg.

diff -r 390ff286651b -r 52803877038a mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sun Jul 14 05:35:04 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sun Jul 14 23:36:01 2013 +0400
@@ -194,9 +194,26 @@
             hi = query
         else:
             hi = 'tip'
+
+        dosearch = False
         try:
-            ctx = web.repo[hi]
-        except (error.RepoError, error.LookupError):
+            hiparts = hi.split(':')
+            if len(hiparts) == 1:
+                ctx = web.repo[hi]
+            elif len(hiparts) == 2:
+                # two parts - check they unambiguously point to the same rev
+                ctx1 = web.repo[hiparts[0]]
+                ctx2 = web.repo[hiparts[1]]
+                if ctx1 == ctx2:
+                    ctx = ctx1
+                else:
+                    dosearch = True
+            else:
+                dosearch = True
+        except (error.RepoError, error.LookupError) as e:
+            dosearch = True
+
+        if dosearch:
             return _search(web, req, tmpl) # XXX redirect to 404 page?
 
     def changelist(latestonly, **map):


More information about the Mercurial-devel mailing list