[PATCH 3 of 6] changeset: add successors method for hg backend

Andrew Shadura andrew at shadura.me
Tue Jul 28 11:02:39 UTC 2015


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1405392766 18000
#      Mon Jul 14 21:52:46 2014 -0500
# Node ID b08991c9389cbc64e5145b71629079fa7059fa6c
# Parent  1d08fb9cd850269f7f771e54f3e9496d49fcb102
changeset: add successors method for hg backend

diff --git a/kallithea/lib/vcs/backends/hg/changeset.py b/kallithea/lib/vcs/backends/hg/changeset.py
--- a/kallithea/lib/vcs/backends/hg/changeset.py
+++ b/kallithea/lib/vcs/backends/hg/changeset.py
@@ -16,6 +16,7 @@ from kallithea.lib.vcs.utils.lazy import
 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 @@ class MercurialChangeset(BaseChangeset):
         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())
 


More information about the kallithea-general mailing list