f6008f722974

Prevent {update} from crashing in empty repos.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 30 Nov 2009 20:25:43 -0500
parents 705378546da2
children 037b7d29d984
branches/tags (none)
files prompt.py

Changes

diff -r 705378546da2 -r f6008f722974 prompt.py
--- a/prompt.py	Mon Nov 30 20:18:53 2009 -0500
+++ b/prompt.py	Mon Nov 30 20:25:43 2009 -0500
@@ -221,9 +221,13 @@
         return _with_groups(m.groups(), path.basename(repo.root)) if repo.root else ''
     
     def _update(m):
-        curr = repo[None].parents()[0]
-        to = repo[repo.branchtags()[curr.branch()]]
-        return _with_groups(m.groups(), '^') if curr != to else ''
+        if not repo.branchtags():
+            # We are in an empty repository.
+            return ''
+        
+        current_rev = repo[None].parents()[0]
+        to = repo[repo.branchtags()[current_rev.branch()]]
+        return _with_groups(m.groups(), '^') if current_rev != to else ''
     
     def _rev(m):
         g = m.groups()