[Svnmerge] [PATCH 2/2] test new functionality in r22788

Dustin J. Mitchell dustin at zmanda.com
Wed Jun 27 22:51:54 PDT 2007


Tests for 'svnmerge init' discovering the correct revisions without
being told.

As before, any feedback is appreciated.  I'll commit if there's no
objection for a few days.

Dustin

-- 
        Dustin J. Mitchell
        Storage Software Engineer, Zmanda, Inc.
        http://www.zmanda.com/
-------------- next part --------------
[[[
* contrib/client-side/svnmerge/svnmerge_test.py: Test determination of
  revisions on 'init' from copyfrom information (functionality added 
  in r22788), and from revision information in an external repository
]]]
Index: fix-tests/svnmerge_test.py
===================================================================
--- fix-tests.orig/svnmerge_test.py	2007-06-28 00:37:10.411685708 -0500
+++ fix-tests/svnmerge_test.py	2007-06-28 00:48:10.777160615 -0500
@@ -321,8 +321,8 @@
     p = os.path.join(temp_path(), "__svnmerge_test_template")
     return os.path.abspath(p)
 
-def get_test_path():
-    p = os.path.join(temp_path(), "__svnmerge_test")
+def get_test_path(suffix=''):
+    p = os.path.join(temp_path(), "__svnmerge_test" + suffix)
     return os.path.abspath(p)
 
 def abspath_to_url(path):
@@ -583,6 +583,72 @@
         p = self.getproperty()
         self.assertEqual("/trunk:1-6", p)
 
+    def testInitExternalRepo(self):
+        """Test that init correctly guesses the revisions that are merged from the
+        copyfrom revision of the merge source."""
+
+        my_test_path = get_test_path("-external")
+        my_test_repo_path = os.path.join(my_test_path, "repo")
+        my_test_repo_url = abspath_to_url(my_test_repo_path)
+        d = locals()
+        print d
+
+        rmtree(my_test_path)
+        try:
+            os.makedirs(my_test_path)
+            os.chdir(my_test_path)
+            self.multilaunch("""
+                svnadmin create --fs-type fsfs %(my_test_repo_path)s
+                svn mkdir -m "create /fakeproj" %(my_test_repo_url)s/fakeproj
+                svn mkdir -m "create /fakeproj/trunk" %(my_test_repo_url)s/fakeproj/trunk
+                svn co %(my_test_repo_url)s/fakeproj/trunk trunk
+            """ % d)
+
+            os.chdir(self.test_path)
+            os.chdir("trunk")
+
+            # Not using switch, so must update to get latest repository rev.
+            self.launch("svn update", match=r"At revision 13")
+            self.svnmerge2(["init", my_test_repo_url + "/fakeproj/trunk"])
+            self.launch("svn commit -F svnmerge-commit-message.txt",
+                        match=r"Committed revision 14")
+
+            # there's no copy here, so 'svnmerge init' looks up the HEAD revision
+            # on /fakeproj/trunk and uses that to construct the initial revisions
+            pmerged = self.getproperty()
+            self.assertEqual("/fakeproj/trunk:1-2", pmerged)
+        finally:
+            rmtree(my_test_path)
+
+    def testInitRevisionInfoFromSource(self):
+        """Test that init correctly guesses the revisions that are merged from the
+        copyfrom revision of the merge source."""
+        os.chdir("..")
+        os.chdir("trunk")
+        # Not using switch, so must update to get latest repository rev.
+        self.launch("svn update", match=r"At revision 13")
+        self.svnmerge2(["init", self.test_repo_url + "/branches/test-branch"])
+        self.launch("svn commit -F svnmerge-commit-message.txt",
+                    match=r"Committed revision 14")
+
+        # /branches/test-branch was copied from /trunk at 6, so the 'init' will only
+        # assume that revisions 1-6 were merged
+        pmerged = self.getproperty()
+        self.assertEqual("/branches/test-branch:1-6", pmerged)
+
+        os.chdir("..")
+        os.chdir("test-branch")
+        # Not using switch, so must update to get latest repository rev.
+        self.launch("svn update", match=r"At revision 14")
+        self.svnmerge2(["init", self.test_repo_url + "/trunk"])
+        self.launch("svn commit -F svnmerge-commit-message.txt",
+                    match=r"Committed revision 15")
+
+        # /trunk was not copied from /branches/test-branch, so the 'init' will take
+        # the head revision of /branches/test-branch as the maximal revision
+        pmerged = self.getproperty()
+        self.assertEqual("/trunk:1-14", pmerged)
+
     def testUninit(self):
         """Test that uninit works, for both merged and blocked revisions."""
         os.chdir("..")


More information about the Svnmerge mailing list