view tests/test-summary.py @ 123:cdde1656346f

client: add 'hidden' property to show hidden changesets. This enables interactions with the obsolete changesets in the repository: - add the attribute in client class - add the keyword to the relevant commands - enable log without hidden changesets even when self.hidden is True - add a few tests with the hidden keyword This changeset mirrors the behavior of the mercurial global command --hidden: an attribute is added to the client library. If set at True, adds the hidden keyword to all command which can use it to show hidden changesets. The alternative would be to add the keyword in rawcommand, but the hidden flag is not relevant for commands such as add or branch.
author Paul Tonelli <paul.tonelli@logilab.fr>
date Thu, 22 May 2014 15:23:12 +0200
parents 3bbf6a3266f4
children 4359cabcb0cc
line wrap: on
line source

import common
import hglib

class test_summary(common.basetest):
    def test_empty(self):
        d = {'parent' : [(-1, '000000000000', 'tip', None)],
             'branch' : 'default',
             'commit' : True,
             'update' : 0}

        self.assertEquals(self.client.summary(), d)

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

        d = {'parent' : [(0, node[:12], 'tip', 'first')],
             'branch' : 'default',
             'commit' : True,
             'update' : 0}

        self.assertEquals(self.client.summary(), d)

    def test_commit_dirty(self):
        self.append('a', 'a')
        rev, node = self.client.commit('first', addremove=True)
        self.append('a', 'a')

        d = {'parent' : [(0, node[:12], 'tip', 'first')],
             'branch' : 'default',
             'commit' : False,
             'update' : 0}

        self.assertEquals(self.client.summary(), d)

    def test_update(self):
        self.append('a', 'a')
        rev, node = self.client.commit('first', addremove=True)
        self.append('a', 'a')
        self.client.commit('second')
        self.client.update(0)

        d = {'parent' : [(0, node[:12], None, 'first')],
             'branch' : 'default',
             'commit' : True,
             'update' : 1}

        self.assertEquals(self.client.summary(), d)

    def test_remote(self):
        self.append('a', 'a')
        rev, node = self.client.commit('first', addremove=True)

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

        d = {'parent' : [(0, node[:12], 'tip', 'first')],
             'branch' : 'default',
             'commit' : True,
             'update' : 0,
             'remote' : (0, 0, 0, 0)}

        self.assertEquals(other.summary(remote=True), d)

        self.append('a', 'a')
        self.client.commit('second')

        d['remote'] = (1, 0, 0, 0)
        self.assertEquals(other.summary(remote=True), d)

        self.client.bookmark('bm')
        d['remote'] = (1, 1, 0, 0)
        self.assertEquals(other.summary(remote=True), d)

        other.bookmark('bmother')
        d['remote'] = (1, 1, 0, 1)
        if self.client.version < (2, 0, 0):
            d['parent'] = [(0, node[:12], 'tip bmother', 'first')]
        else:
            d['bookmarks'] = '*bmother'
        self.assertEquals(other.summary(remote=True), d)

        self.append('other/a', 'a')
        rev, node = other.commit('second in other')

        d['remote'] = (1, 1, 1, 1)
        if self.client.version < (2, 0, 0):
            tags = 'tip bmother'
        else:
            tags = 'tip'
        d['parent'] = [(1, node[:12], tags, 'second in other')]

        self.assertEquals(other.summary(remote=True), d)

    def test_two_parents(self):
        self.append('a', 'a')
        rev0, node = self.client.commit('first', addremove=True)

        self.append('a', 'a')
        rev1, node1 = self.client.commit('second')

        self.client.update(rev0)
        self.append('b', 'a')
        rev2, node2 = self.client.commit('third', addremove=True)

        self.client.merge(rev1)

        d = {'parent' : [(2, node2[:12], 'tip', 'third'),
                         (1, node1[:12], None, 'second')],
             'branch' : 'default',
             'commit' : False,
             'update' : 0}

        self.assertEquals(self.client.summary(), d)