diff tests/test_fetch_branches.py @ 304:ce676eff002b

First merge, totally untested.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 01 May 2009 10:28:59 +0200
parents f8f9a2993705
children 942f198b8ff5
line wrap: on
line diff
--- a/tests/test_fetch_branches.py
+++ b/tests/test_fetch_branches.py
@@ -1,14 +1,24 @@
 import unittest
 
+from mercurial import hg
 from mercurial import node
+from mercurial import ui
 
 import test_util
+import wrappers
 
 
 class TestFetchBranches(test_util.TestBase):
-    def _load_fixture_and_fetch(self, fixture_name, stupid):
+    def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True):
         return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
-                                                self.wc_path, stupid=stupid)
+                                                self.wc_path, stupid=stupid,
+                                                noupdate=noupdate)
+
+    def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor):
+        test_util.load_svndump_fixture(self.repo_path, fixture_name)
+        source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor)
+        wrappers.clone(None, ui.ui(), source=source, dest=self.wc_path)
+        return hg.repository(ui.ui(), self.wc_path)
 
     def test_unrelatedbranch(self, stupid=False):
         repo = self._load_fixture_and_fetch('unrelatedbranch.svndump', stupid)
@@ -53,6 +63,27 @@ class TestFetchBranches(test_util.TestBa
     def test_replace_trunk_with_branch_stupid(self):
         self.test_replace_trunk_with_branch(stupid=True)
 
+    def test_branch_create_with_dir_delete_works(self, stupid=False):
+        repo = self._load_fixture_and_fetch('branch_create_with_dir_delete.svndump',
+                                            stupid)
+        self.assertEqual(repo['tip'].manifest().keys(),
+                         ['alpha', 'beta', 'iota', 'gamma', ])
+
+    def test_branch_tip_update_to_default(self, stupid=False):
+        repo = self._load_fixture_and_fetch('unorderedbranch.svndump',
+                                            stupid, noupdate=False)
+        self.assertEqual(repo[None].branch(), 'default')
+        self.assertTrue('tip' not in repo[None].tags())
+    
+    def test_branch_tip_update_to_default_stupid(self):
+        self.test_branch_tip_update_to_default(True)
+    
+    def test_branch_tip_update_to_branch_anchor(self):
+        repo = self._load_fixture_and_fetch_with_anchor(
+            'unorderedbranch.svndump', 'branch')
+        self.assertEqual(repo[None].branch(), 'branch')
+        self.assertEqual(repo[None].parents()[0], repo[repo.branchheads()[0]])
+
 def suite():
     all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches),
           ]