Changeset - d1b07a8b2b00
[Not reviewed]
default
0 2 0
Manuel Jacob - 7 years ago 2019-02-18 23:58:33
me@manueljacob.de
hg: make `successors` property of MercurialChangeset compatible with newer versions of Mercurial.
2 files changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -79,25 +79,29 @@ class MercurialChangeset(BaseChangeset):
 

	
 
    @LazyProperty
 
    def phase(self):
 
        if(self._ctx.phase() == 1):
 
            return 'Draft'
 
        elif(self._ctx.phase() == 2):
 
            return 'Secret'
 
        else:
 
            return ''
 

	
 
    @LazyProperty
 
    def successors(self):
 
        successors = obsolete.successorssets(self._ctx._repo, self._ctx.node())
 
        try:
 
            from mercurial import obsutil
 
            successors = obsutil.successorssets(self._ctx._repo, self._ctx.node())
 
        except ImportError:  # moved in Mercurial 4.3 (4f49810a1011)
 
            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 predecessors(self):
 
        predecessors = set()
 
        nm = self._ctx._repo.changelog.nodemap
 
        for p in self._ctx._repo.obsstore.precursors.get(self._ctx.node(), ()):
kallithea/tests/vcs/test_hg.py
Show inline comments
 
@@ -576,21 +576,20 @@ class TestMercurialChangeset(object):
 
        pass
 

	
 
    def test_author_email(self):
 
        assert 'marcin@python-blog.com' == self.repo.get_changeset('b986218ba1c9').author_email
 
        assert 'lukasz.balcerzak@python-center.pl' == self.repo.get_changeset('3803844fdbd3').author_email
 
        assert '' == self.repo.get_changeset('84478366594b').author_email
 

	
 
    def test_author_username(self):
 
        assert 'Marcin Kuzminski' == self.repo.get_changeset('b986218ba1c9').author_name
 
        assert 'Lukasz Balcerzak' == self.repo.get_changeset('3803844fdbd3').author_name
 
        assert 'marcink' == self.repo.get_changeset('84478366594b').author_name
 

	
 
    @pytest.mark.xfail
 
    def test_successors(self):
 
        init_chset = self.repo.get_changeset(0)
 
        assert init_chset.successors == []
 

	
 
    @pytest.mark.xfail
 
    def test_predecessors(self):
 
        init_chset = self.repo.get_changeset(0)
 
        assert init_chset.predecessors == set([])
0 comments (0 inline, 0 general)