f0e69918f2f3

Add the root and root|basename keywords.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 14 Jul 2009 07:23:46 -0400
parents 95281c1ac8a0
children 257f4349747c
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Tue Jul 14 07:12:19 2009 -0400
+++ b/prompt.py	Tue Jul 14 07:23:46 2009 -0400
@@ -9,6 +9,7 @@
 '''
 
 import re
+from os import path
 from mercurial import extensions
 
 def _with_groups(m, out):
@@ -68,12 +69,20 @@
         except KeyError:
             return ''
     
+    def _root(m):
+        return _with_groups(m, repo.root) if repo.root else ''
+    
+    def _basename(m):
+        return _with_groups(m, path.basename(repo.root)) if repo.root else ''
+    
     tag_start = r'\{([^{}]*?\{)?'
     tag_end = r'(\}[^{}]*?)?\}'
     patterns = {
         'branch': _branch,
         'status': _status,
         'bookmark': _bookmark,
+        'root': _root,
+        'root\|basename': _basename,
     }
     
     for tag, repl in patterns.items():