diff tests/test_unaffected_core.py @ 713:69c0e7c4faf9

clone: call the wrapped function (fixes #181) This is a regression that was brought to my attention in #mercurial: hgsubversion breaks the --update flag. The cause is that we call hg.clone() directly rather than the original wrapped function. A comment in 'wrapper.py' noted that the call to hg.clone() should be kept in sync with 'mercurial/commands.py'. That didn't happen. The original reason for calling hg.clone() directly was that we needed its return values. Another wrapper is added (and cleared) within clone() to get them anyway.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 29 Sep 2010 18:04:26 +0200
parents
children f07bfd66db13
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/tests/test_unaffected_core.py
@@ -0,0 +1,85 @@
+import test_util
+
+import os
+import unittest
+
+from mercurial import commands
+from mercurial import dispatch
+from mercurial import error
+from mercurial import hg
+from mercurial import node
+from mercurial import ui
+
+class TestMercurialCore(test_util.TestBase):
+    '''
+    Test that the core Mercurial operations aren't broken by hgsubversion.
+    '''
+
+    @test_util.requiresoption('updaterev')
+    def test_update(self):
+        ''' Test 'clone --updaterev' '''
+        ui = self.ui()
+        dispatch._dispatch(ui, ['init', self.wc_path])
+        repo = self.repo
+        repo.ui.setconfig('ui', 'username', 'anonymous')
+
+        fpath = os.path.join(self.wc_path, 'it')
+        f = file(fpath, 'w')
+        f.write('C1')
+        f.flush()
+        commands.add(ui, repo)
+        commands.commit(ui, repo, message="C1")
+        f.write('C2')
+        f.flush()
+        commands.commit(ui, repo, message="C2")
+        f.write('C3')
+        f.flush()
+        commands.commit(ui, repo, message="C3")
+
+        self.assertEqual(len(repo), 3)
+
+        updaterev = 1
+        dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
+                                '--updaterev=%s' % updaterev])
+
+        repo2 = hg.repository(ui, self.wc_path + '2')
+
+        self.assertEqual(str(repo[updaterev]), str(repo2['.']))
+
+    @test_util.requiresoption('branch')
+    def test_branch(self):
+        ''' Test 'clone --branch' '''
+        ui = self.ui()
+        dispatch._dispatch(ui, ['init', self.wc_path])
+        repo = self.repo
+        repo.ui.setconfig('ui', 'username', 'anonymous')
+
+        fpath = os.path.join(self.wc_path, 'it')
+        f = file(fpath, 'w')
+        f.write('C1')
+        f.flush()
+        commands.add(ui, repo)
+        commands.branch(ui, repo, label="B1")
+        commands.commit(ui, repo, message="C1")
+        f.write('C2')
+        f.flush()
+        commands.branch(ui, repo, label="default")
+        commands.commit(ui, repo, message="C2")
+        f.write('C3')
+        f.flush()
+        commands.branch(ui, repo, label="B2")
+        commands.commit(ui, repo, message="C3")
+
+        self.assertEqual(len(repo), 3)
+
+        branch = 'B1'
+        dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
+                                '--branch', branch])
+
+        repo2 = hg.repository(ui, self.wc_path + '2')
+
+        self.assertEqual(repo[branch].hex(), repo2['.'].hex())
+
+def suite():
+    all = [unittest.TestLoader().loadTestsFromTestCase(TestMercurialCore)]
+    return unittest.TestSuite(all)