فهرست منبع

Merge fix for crashing empty time-based walkers.

Jelmer Vernooij 12 سال پیش
والد
کامیت
e84e5251a8
2فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 4 0
      dulwich/tests/test_walk.py
  2. 1 1
      dulwich/walk.py

+ 4 - 0
dulwich/tests/test_walk.py

@@ -410,3 +410,7 @@ class WalkerTest(TestCase):
         # Ensure that c1..y4 get excluded even though they're popped from the
         # priority queue long before y5.
         self.assertWalkYields([m6, x2], [m6.id], exclude=[y5.id])
+
+    def test_empty_walk(self):
+        c1, c2, c3 = self.make_linear_commits(3)
+        self.assertWalkYields([], [c3.id], exclude=[c3.id])

+ 1 - 1
dulwich/walk.py

@@ -153,7 +153,7 @@ class _CommitTimeQueue(object):
                 if self._pq and all(c.id in self._excluded
                                     for _, c in self._pq):
                     _, n = self._pq[0]
-                    if n.commit_time >= self._last.commit_time:
+                    if self._last and n.commit_time >= self._last.commit_time:
                         # If the next commit is newer than the last one, we need
                         # to keep walking in case its parents (which we may not
                         # have seen yet) are excluded. This gives the excluded