view tests/test_outgoing_incoming.py @ 226:7b6ea46ea111

setup.py: clean up use of os.popen
author Mathias De Mare <mathias.de_mare@nokia.com>
date Tue, 14 Mar 2023 10:23:08 +0100
parents a2afbf236ca8
children
line wrap: on
line source

from tests import common
import hglib
from hglib.util import b

class test_outgoing_incoming(common.basetest):
    def test_no_path(self):
        self.assertRaises(hglib.error.CommandError, self.client.incoming)

    def test_empty(self):
        self.client.clone(dest=b('other'))
        self.other = hglib.open(b('other'))

        self.assertEqual(self.other.incoming(), [])
        self.assertEqual(self.other.outgoing(), [])

    def test_basic(self):
        self.append('a', 'a')
        self.client.commit(b('first'), addremove=True)
        self.append('a', 'a')
        self.client.commit(b('second'))

        self.client.clone(dest=b('other'))
        other = hglib.open(b('other'))

        self.assertEqual(self.client.log(), other.log())
        self.assertEqual(self.client.outgoing(path=b('other')),
                          other.incoming())

        self.append('a', 'a')
        rev, node = self.client.commit(b('third'))
        out = self.client.outgoing(path=b('other'))

        self.assertEqual(len(out), 1)
        self.assertEqual(out[0].node, node)

        self.assertEqual(out, other.incoming())

    def test_bookmarks(self):
        self.append('a', 'a')
        self.client.commit(b('first'), addremove=True)
        self.append('a', 'a')
        self.client.commit(b('second'))

        self.client.clone(dest=b('other'))
        other = hglib.open(b('other'))

        self.client.bookmark(b('bm1'), 1)

        self.assertEqual(other.incoming(bookmarks=True),
                          [(b('bm1'), self.client.tip().node[:12])])

        self.assertEqual(self.client.outgoing(path=b('other'), bookmarks=True),
                          [(b('bm1'), self.client.tip().node[:12])])