Mercurial > python-hglib
view tests/test_update.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 from hglib import error from hglib.util import b, strtobytes class test_update(common.basetest): def setUp(self): common.basetest.setUp(self) self.append('a', 'a') self.rev0, self.node0 = self.client.commit(b('first'), addremove=True) self.append('a', 'a') self.rev1, self.node1 = self.client.commit(b('second')) def test_basic(self): u, m, r, ur = self.client.update(self.rev0) self.assertEqual(u, 1) self.assertEqual(m, 0) self.assertEqual(r, 0) self.assertEqual(ur, 0) def test_unresolved(self): self.client.update(self.rev0) self.append('a', 'b') u, m, r, ur = self.client.update() self.assertEqual(u, 0) self.assertEqual(m, 0) self.assertEqual(r, 0) self.assertEqual(ur, 1) self.assertTrue((b('M'), b('a')) in self.client.status()) def test_merge(self): self.append('a', '\n\n\n\nb') rev2, node2 = self.client.commit(b('third')) self.append('a', 'b') self.client.commit(b('fourth')) self.client.update(rev2) with open('a') as f: old = f.read() f = open('a', 'wb') f.write(b('a') + old.encode('latin-1')) f.close() u, m, r, ur = self.client.update() self.assertEqual(u, 0) self.assertEqual(m, 1) self.assertEqual(r, 0) self.assertEqual(ur, 0) self.assertEqual(self.client.status(), [(b('M'), b('a'))]) def test_tip(self): self.client.update(self.rev0) u, m, r, ur = self.client.update() self.assertEqual(u, 1) self.assertEqual(self.client.parents()[0].node, self.node1) self.client.update(self.rev0) self.append('a', 'b') rev2, node2 = self.client.commit(b('new head')) self.client.update(self.rev0) self.client.update() self.assertEqual(self.client.parents()[0].node, node2) def test_check_clean(self): self.assertRaises(ValueError, self.client.update, clean=True, check=True) def test_clean(self): with open('a') as f: old = f.read() self.append('a', 'b') self.assertRaises(error.CommandError, self.client.update, check=True) u, m, r, ur = self.client.update(clean=True) self.assertEqual(u, 1) with open('a') as f: self.assertEqual(old, f.read()) def test_basic_plain(self): f = open('.hg/hgrc', 'a') f.write('[defaults]\nupdate=-v\n') f.close() self.test_basic() def disabled_largefiles(self): # we don't run reposetup after a session has started, so this # test is broken import os f = open('.hg/hgrc', 'a') f.write('[extensions]\nlargefiles=\n') f.close() self.append('b', 'a') try: self.client.rawcommand([b('add'), b('b'), b('--large')]) except error.CommandError: return rev2, node2 = self.client.commit(b('third')) # Go back to 0 self.client.rawcommand([b('update'), strtobytes(self.rev0)], # Keep the 'changed' version prompt=lambda s, d: 'c\n') u, m, r, ur = self.client.update(rev2, clean=True) self.assertEqual(u, 2) self.assertEqual(m, 0) self.assertEqual(r, 0) self.assertEqual(ur, 0)