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): """ @@ -43,6 +44,30 @@ class MercurialChangeset(BaseChangeset): return self._ctx.closesbranch() @LazyProperty + def obsolete(self): + 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 precursors(self): + precursors = set() + nm = self._ctx._repo.changelog.nodemap + for p in self._ctx._repo.obsstore.precursors.get(self._ctx.node(), ()): + pr = nm.get(p[0]) + if pr is not None: + precursors.add(hex(p[0])[:12]) + return precursors + + @LazyProperty def bookmarks(self): return map(safe_unicode, self._ctx.bookmarks()) @@ -284,13 +309,6 @@ class MercurialChangeset(BaseChangeset): archival.archive(self.repository._repo, stream, self.raw_id, kind, prefix=prefix, subrepos=subrepos) - if stream.closed and hasattr(stream, 'name'): - stream = open(stream.name, 'rb') - elif hasattr(stream, 'mode') and 'r' not in stream.mode: - stream = open(stream.name, 'rb') - else: - stream.seek(0) - def get_nodes(self, path): """ Returns combined ``DirNode`` and ``FileNode`` objects list representing