瀏覽代碼

Deprecate Tree.entries.

Jelmer Vernooij 14 年之前
父節點
當前提交
10eaad8509
共有 5 個文件被更改,包括 12 次插入4 次删除
  1. 5 0
      NEWS
  2. 1 1
      dulwich/object_store.py
  3. 3 0
      dulwich/objects.py
  4. 2 2
      dulwich/tests/test_objects.py
  5. 1 1
      dulwich/tests/test_repository.py

+ 5 - 0
NEWS

@@ -16,6 +16,11 @@
 
 
   * Sphinxified documentation. (Lukasz Balcerzak)
   * Sphinxified documentation. (Lukasz Balcerzak)
 
 
+ API CHANGES
+
+  * Tree.entries() is now deprecated in favour of Tree.items() and
+    Tree.iteritems(). (Jelmer Vernooij)
+
 0.7.0	2011-01-21
 0.7.0	2011-01-21
 
 
  FEATURES
  FEATURES

+ 1 - 1
dulwich/object_store.py

@@ -698,7 +698,7 @@ class MissingObjectFinder(object):
 
 
     def parse_tree(self, tree):
     def parse_tree(self, tree):
         self.add_todo([(sha, name, not stat.S_ISDIR(mode))
         self.add_todo([(sha, name, not stat.S_ISDIR(mode))
-                       for mode, name, sha in tree.entries()
+                       for name, mode, sha in tree.iteritems()
                        if not S_ISGITLINK(mode)])
                        if not S_ISGITLINK(mode)])
 
 
     def parse_commit(self, commit):
     def parse_commit(self, commit):

+ 3 - 0
dulwich/objects.py

@@ -838,6 +838,9 @@ class Tree(ShaFile):
             returned by the items and iteritems methods. This function will be
             returned by the items and iteritems methods. This function will be
             deprecated in the future.
             deprecated in the future.
         """
         """
+        warnings.warn("Tree.entries() is deprecated. Use Tree.items() or"
+            " Tree.iteritems() instead.", category=DeprecationWarning,
+            stacklevel=2)
         self._ensure_parsed()
         self._ensure_parsed()
         # The order of this is different from iteritems() for historical
         # The order of this is different from iteritems() for historical
         # reasons
         # reasons

+ 2 - 2
dulwich/tests/test_objects.py

@@ -150,8 +150,8 @@ class BlobReadTests(TestCase):
 
 
     def test_read_tree_from_file(self):
     def test_read_tree_from_file(self):
         t = self.get_tree(tree_sha)
         t = self.get_tree(tree_sha)
-        self.assertEqual(t.entries()[0], (33188, 'a', a_sha))
-        self.assertEqual(t.entries()[1], (33188, 'b', b_sha))
+        self.assertEqual(t.items()[0], ('a', 33188, a_sha))
+        self.assertEqual(t.items()[1], ('b', 33188, b_sha))
 
 
     def test_read_tag_from_file(self):
     def test_read_tag_from_file(self):
         t = self.get_tag(tag_sha)
         t = self.get_tag(tag_sha)

+ 1 - 1
dulwich/tests/test_repository.py

@@ -239,7 +239,7 @@ class RepositoryTests(TestCase):
         r = self._repo = open_repo('a.git')
         r = self._repo = open_repo('a.git')
         commit = r[r.head()]
         commit = r[r.head()]
         tree = r[commit.tree]
         tree = r[commit.tree]
-        blob_sha = tree.entries()[0][2]
+        blob_sha = tree.items()[0][2]
         warnings.simplefilter("ignore", DeprecationWarning)
         warnings.simplefilter("ignore", DeprecationWarning)
         try:
         try:
             blob = r.get_blob(blob_sha)
             blob = r.get_blob(blob_sha)