a62c8ab6c87f

added task keyword
[view raw] [browse files]
author pjv <pjv@cyberplexus.com>
date Wed, 22 Jul 2009 21:23:31 -0500
parents 923467766eba
children c2f93120c221
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Thu Jul 16 16:54:49 2009 -0400
+++ b/prompt.py	Wed Jul 22 21:23:31 2009 -0500
@@ -1,5 +1,8 @@
 #!/usr/bin/env python
 
+# Uncomment next line if using python 2.5x
+from __future__ import with_statement
+
 '''get repository information for use in a shell prompt
 
 Take a string, parse any special variables inside, and output the result.
@@ -107,6 +110,13 @@
         except KeyError:
             return ''
     
+    def _task(m):
+        try:
+            task = extensions.find('tasks').current(repo)
+            return _with_groups(m.groups(), task) if task else ''
+        except KeyError:
+            return ''
+    
     def _root(m):
         return _with_groups(m.groups(), repo.root) if repo.root else ''
     
@@ -149,6 +159,7 @@
         'branch': _branch,
         'status': _status,
         'bookmark': _bookmark,
+        'task': _task,
         'root': _root,
         'root\|basename': _basename,
         'incoming(\|count)?': _remote('incoming'),
@@ -172,4 +183,4 @@
         ('', 'cache-outgoing', None, 'used internally by hg-prompt'),
     ],
     'hg prompt STRING')
-}
\ No newline at end of file
+}