changeset 5349:2978928a95ea

changeset: add successors method for hg backend
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 14 Jul 2014 21:52:46 -0500
parents 46d42b34cf3e
children 8737030a9550
files kallithea/lib/vcs/backends/hg/changeset.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/hg/changeset.py	Wed Jul 09 14:09:19 2014 -0500
+++ b/kallithea/lib/vcs/backends/hg/changeset.py	Mon Jul 14 21:52:46 2014 -0500
@@ -16,6 +16,7 @@
 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
 from kallithea.lib.vcs.utils.hgcompat import archival, hex
 
+from mercurial import obsolete
 
 class MercurialChangeset(BaseChangeset):
     """
@@ -47,6 +48,16 @@
         return  self._ctx.obsolete()
 
     @LazyProperty
+    def successors(self):
+        successors = obsolete.successorssets(self._ctx._repo, self._ctx.node())
+        if successors:
+            # flatten the list here handles both divergent (len > 1)
+            # and the usual case (len = 1)
+            successors = [hex(n)[:12] for sub in successors for n in sub if n != self._ctx.node()]
+
+        return successors
+
+    @LazyProperty
     def bookmarks(self):
         return map(safe_unicode, self._ctx.bookmarks())