Merge ~cjwatson/turnip:log-missing-stop into turnip:master

Proposed by Colin Watson
Status: Needs review
Proposed branch: ~cjwatson/turnip:log-missing-stop
Merge into: turnip:master
Prerequisite: ~cjwatson/turnip:log-by-date
Diff against target: 36 lines (+13/-1)
2 files modified
turnip/api/store.py (+4/-1)
turnip/api/tests/test_api.py (+9/-0)
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+295545@code.launchpad.net

Commit message

Make log API ignore a missing stop commit

Determining whether the stop commit exists in advance requires an extra
round-trip, and clients are likely to just fall back to omitting the
stop commit anyway. start_time and end_time provide an alternative way
to bound the set of commits which can be used in addition to a
possibly-missing stop commit.

Description of the change

Make log API ignore a missing stop commit.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

This makes it very easily to accidentally request a couple of hundred thousand commits, but I understand the motivation.

review: Approve (code)

Unmerged commits

56c15c5... by Colin Watson

Make log API ignore a missing stop commit

Determining whether the stop commit exists in advance requires an extra
round-trip, and clients are likely to just fall back to omitting the
stop commit anyway. start_time and end_time provide an alternative way
to bound the set of commits which can be used in addition to a
possibly-missing stop commit.

ee4cd2f... by Colin Watson

Add start_time and end_time parameters to log API

This is useful for bounding the set of commits returned in cases where
we may not have a reliable stop commit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/turnip/api/store.py b/turnip/api/store.py
index 0b08fa9..9759fd8 100644
--- a/turnip/api/store.py
+++ b/turnip/api/store.py
@@ -414,7 +414,10 @@ def get_log(repo_store, repo_name, start=None, limit=None, stop=None,
414 start = repo.head.target # walk from HEAD414 start = repo.head.target # walk from HEAD
415 walker = repo.walk(start)415 walker = repo.walk(start)
416 if stop:416 if stop:
417 walker.hide(stop) # filter stop sha1 and its ancestors417 try:
418 walker.hide(stop) # filter stop sha1 and its ancestors
419 except KeyError:
420 pass
418 if limit > 0:421 if limit > 0:
419 walker = itertools.islice(walker, limit)422 walker = itertools.islice(walker, limit)
420 for commit in walker:423 for commit in walker:
diff --git a/turnip/api/tests/test_api.py b/turnip/api/tests/test_api.py
index 065b067..7b2511b 100644
--- a/turnip/api/tests/test_api.py
+++ b/turnip/api/tests/test_api.py
@@ -558,6 +558,15 @@ class ApiTestCase(TestCase):
558 self.assertEqual(5, len(resp.json))558 self.assertEqual(5, len(resp.json))
559 self.assertNotIn(excluded_commit, resp.json)559 self.assertNotIn(excluded_commit, resp.json)
560560
561 def test_repo_get_log_with_missing_stop(self):
562 """A missing stop commit is ignored rather than crashing."""
563 factory = RepoFactory(self.repo_store, num_commits=10)
564 repo = factory.build()
565 head = repo.head.target
566 resp = self.app.get('/repo/{}/log/{}?stop={}'.format(
567 self.repo_path, head, factory.nonexistent_oid()))
568 self.assertEqual(10, len(resp.json))
569
561 def test_repo_repack_verify_pack(self):570 def test_repo_repack_verify_pack(self):
562 """Ensure commit exists in pack."""571 """Ensure commit exists in pack."""
563 factory = RepoFactory(self.repo_store)572 factory = RepoFactory(self.repo_store)

Subscribers

People subscribed via source and target branches