Patchwork [2,of,3] obsolete: introduce a troubles method on context

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 17, 2012, 2:41 p.m.
Message ID <5eca666b0078061addf6.1355755278@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/153/
State Accepted
Commit 5b117f82cbdb9b082ce59024193cf0a302bee105
Headers show

Comments

Pierre-Yves David - Dec. 17, 2012, 2:41 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1355753874 -3600
# Node ID 5eca666b0078061addf65b5f431207db21839ebd
# Parent  3e51efedc357cc451eee807e861efb905de00331
obsolete: introduce a troubles method on context

A troubled changeset may be affected by multiple trouble at the same time. This
new method returns a list of all troubles affecting a changes.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -262,10 +262,27 @@  class changectx(object):
 
     def troubled(self):
         """True if the changeset is either unstable, bumped or divergent"""
         return self.unstable() or self.bumped() or self.divergent()
 
+    def troubles(self):
+        """return the list of troubles affecting this changesets.
+
+        Troubles are returned as strings. possible values are:
+        - unstable,
+        - bumped,
+        - divergent.
+        """
+        troubles = []
+        if self.unstable():
+            troubles.append('unstable')
+        if self.bumped():
+            troubles.append('bumped')
+        if self.divergent():
+            troubles.append('divergent')
+        return troubles
+
     def _fileinfo(self, path):
         if '_manifest' in self.__dict__:
             try:
                 return self._manifest[path], self._manifest.flags(path)
             except KeyError: