comparison tests/test_pull.py @ 908:c4ee11a5d04c

pull: add a hgsubversion.unsafeskip option to omit unwanted revs
author Bryan O'Sullivan <bryano@fb.com>
date Wed, 16 May 2012 16:52:25 -0700
parents cc1c870f1758
children d741f536f23a
comparison
equal deleted inserted replaced
907:173065f9b715 908:c4ee11a5d04c
4 import subprocess 4 import subprocess
5 from mercurial import node 5 from mercurial import node
6 from mercurial import ui 6 from mercurial import ui
7 from mercurial import util as hgutil 7 from mercurial import util as hgutil
8 from mercurial import commands 8 from mercurial import commands
9 from hgsubversion import verify
9 10
10 class TestPull(test_util.TestBase): 11 class TestPull(test_util.TestBase):
11 def setUp(self): 12 def setUp(self):
12 super(TestPull, self).setUp() 13 super(TestPull, self).setUp()
13 14
14 def _loadupdate(self, fixture_name): 15 def _loadupdate(self, fixture_name, *args, **kwargs):
15 repo, repo_path = self.load_and_fetch(fixture_name, stupid=False, 16 kwargs = kwargs.copy()
16 noupdate=False) 17 kwargs.update(stupid=False, noupdate=False)
18 repo, repo_path = self.load_and_fetch(fixture_name, *args, **kwargs)
17 return repo, repo_path 19 return repo, repo_path
18 20
19 def test_nochanges(self): 21 def test_nochanges(self):
20 self._loadupdate('single_rev.svndump') 22 self._loadupdate('single_rev.svndump')
21 state = self.repo.parents() 23 state = self.repo.parents()
56 repo = self._loadupdate('branchtagcollision.svndump')[0] 58 repo = self._loadupdate('branchtagcollision.svndump')[0]
57 oldheads = map(node.hex, repo.heads()) 59 oldheads = map(node.hex, repo.heads())
58 commands.pull(repo.ui, repo) 60 commands.pull(repo.ui, repo)
59 self.assertEqual(oldheads, map(node.hex, repo.heads())) 61 self.assertEqual(oldheads, map(node.hex, repo.heads()))
60 62
63 def test_skip_basic(self):
64 repo, repo_path = self._loadupdate('single_rev.svndump')
65 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
66 self.add_svn_rev(repo_path, {'trunk/beta': 'More changed'})
67 self.add_svn_rev(repo_path, {'trunk/gamma': 'Even more changeder'})
68 repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
69 commands.pull(repo.ui, repo)
70 tip = repo['tip'].rev()
71 self.assertEqual(tip, 1)
72 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 1)
73
74 def test_skip_delete_restore(self):
75 repo, repo_path = self._loadupdate('delete_restore_trunk.svndump',
76 rev=2)
77 repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
78 commands.pull(repo.ui, repo)
79 tip = repo['tip'].rev()
80 self.assertEqual(tip, 1)
81 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 0)
82
61 def suite(): 83 def suite():
62 import unittest, sys 84 import unittest, sys
63 return unittest.findTestCases(sys.modules[__name__]) 85 return unittest.findTestCases(sys.modules[__name__])