Commits

Christian Boos committed b66b432

0.11.5dev: add unit tests for `SubversionNode.get_copy_ancestry`.

  • Participants
  • Parent commits 8496dc9
  • Branches 0.11-stable

Comments (0)

Files changed (2)

trac/versioncontrol/svn_fs.py

                             self.pool())
 
     def get_copy_ancestry(self):
+        """Retrieve the list of `(path,rev)` copy ancestors of this node.
+        Most recent ancestor first. Each ancestor `(path, rev)` corresponds 
+        to the path and revision of the source at the time the copy or move
+        operation was performed.
+        """
         ancestors = []
         previous = (self._scoped_path_utf8, self._requested_rev, self.root)
         while previous:

trac/versioncontrol/tests/svn_fs.py

         self.assertEqual((u'tête/README.txt', 2, 'add'), history.next())
         self.assertRaises(StopIteration, history.next)
 
+    def test_get_copy_ancestry(self):
+        node = self.repos.get_node('/tags/v1/README.txt')
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'tête/README.txt', 6)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
+        node = self.repos.get_node(u'/tête/README3.txt')
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'tête/README2.txt', 13), 
+                          (u'tête/README.txt', 3)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
+        node = self.repos.get_node('/branches/v1x')
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'tags/v1.1', 11),
+                          (u'branches/v1x', 9), 
+                          (u'tags/v1', 7), 
+                          (u'tête', 6)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
+    def test_get_copy_ancestry_for_move(self):
+        node = self.repos.get_node(u'/tête/dir1/dir2', 5)
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'tête/dir2', 4)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
     # Revision Log / path history 
 
     def test_get_path_history(self):
         self.assertEqual(('dir3', 4, 'add'), history.next())
         self.assertRaises(StopIteration, history.next)
 
+    def test_get_copy_ancestry(self):
+        node = self.repos.get_node(u'/README3.txt')
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'README2.txt', 13), 
+                          (u'README.txt', 3)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
+    def test_get_copy_ancestry_for_move(self):
+        node = self.repos.get_node(u'/dir1/dir2', 5)
+        ancestry = node.get_copy_ancestry()
+        self.assertEqual([(u'dir2', 4)], ancestry)
+        for path, rev in ancestry:
+            self.repos.get_node(path, rev) # shouldn't raise NoSuchNode
+
     # Revision Log / path history 
 
     def test_get_path_history(self):