e2d60e4e3caf

Fix error: don't assume status is a tuple

This fix also works with older versions of Mercurial. `repo.status()` used to
return a named tuple; since 5.2.1 it returns an object. So `st[:5]` no longer
works, but `st.modified` works with both old and new versions of Mercurial.
[view raw] [browse files]
author Sietse Brouwer <sbbrouwer@gmail.com>
date Tue, 26 May 2020 14:57:58 +0200
parents cc789a5baf4a
children 25b0cf6b43f5
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Tue May 26 15:08:02 2020 +0200
+++ b/prompt.py	Tue May 26 14:57:58 2020 +0200
@@ -279,9 +279,9 @@
     def _status(m):
         g = m.groups()
 
-        st = repo.status(unknown=True)[:5]
-        modified = any(st[:4])
-        unknown = len(st[-1]) > 0
+        st = repo.status(unknown=True)
+        modified = any((st.modified, st.added, st.removed, st.deleted))
+        unknown = len(st.unknown) > 0
 
         flag = ''
         if '|modified' not in g and '|unknown' not in g: