e1c8340a2a3a

Add a {tip} keyword.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Nov 2009 15:50:53 -0500
parents ce8ef31a90ef
children 272a76c50002
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Sun Oct 04 01:24:35 2009 -0500
+++ b/prompt.py	Sun Nov 08 15:50:53 2009 -0500
@@ -211,6 +211,16 @@
         
         rev = parents[parent].rev() if parent is not None else -1
         return _with_groups(out_g, str(rev)) if rev >= 0 else ''
+    def _tip(m):
+        g = m.groups()
+        out_g = (g[0],) + (g[-1],)
+        
+        format = short if '|short' in g else hex
+        
+        tip = repo[len(repo) - 1]
+        tip = format(tip.node()) if '|node' in g else tip.rev()
+        
+        return _with_groups(out_g, str(tip)) if tip >= 0 else ''
     
     def _node(m):
         g = m.groups()
@@ -268,6 +278,7 @@
         'status(?:(\|modified)|(\|unknown))*': _status,
         'tags(\|[^}]*)?': _tags,
         'task': _task,
+        'tip(?:(\|node)|(\|short))*?': _tip,
         'update': _update,
         
         'incoming(\|count)?': _remote('incoming'),