c9a86b8b497c

Add the {rev} and {rev|merge} keywords.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 23 Jul 2009 03:13:55 -0400
parents b2e16a4c2d46
children ee24c2fdbfba
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Thu Jul 23 02:40:12 2009 -0400
+++ b/prompt.py	Thu Jul 23 03:13:55 2009 -0400
@@ -131,6 +131,17 @@
         to = repo[repo.branchtags()[curr.branch()]]
         return _with_groups(m.groups(), '^') if curr != to else ''
     
+    def _rev(m):
+        g = m.groups()
+        out_g = (g[0],) + (g[-1],)
+        
+        parents = repo[None].parents()
+        p = 0 if '|merge' not in g else 1
+        p = p if len(parents) > p else None
+        
+        rev = parents[p].rev() if p is not None else None
+        return _with_groups(out_g, str(rev)) if rev else ''
+    
     def _remote(kind):
         def _r(m):
             g = m.groups()
@@ -166,6 +177,7 @@
     patterns = {
         'bookmark': _bookmark,
         'branch': _branch,
+        'rev(\|merge)?': _rev,
         'root': _root,
         'root\|basename': _basename,
         'status': _status,