Merge lp:~jelmer/brz/no-such-revision into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/no-such-revision
Merge into: lp:brz/3.1
Diff against target: 49 lines (+14/-0)
2 files modified
breezy/git/remote.py (+6/-0)
breezy/tests/per_controldir/test_push.py (+8/-0)
To merge this branch: bzr merge lp:~jelmer/brz/no-such-revision
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+386358@code.launchpad.net

Commit message

Raise NoSuchRevision rather than KeyError.

Description of the change

Raise NoSuchRevision rather than KeyError.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2020-06-21 22:11:03 +0000
+++ breezy/git/remote.py 2020-06-25 00:07:00 +0000
@@ -593,6 +593,9 @@
593 # No revision supplied by the user, default to the branch593 # No revision supplied by the user, default to the branch
594 # revision594 # revision
595 revision_id = source.last_revision()595 revision_id = source.last_revision()
596 else:
597 if not source.repository.has_revision(revision_id):
598 raise NoSuchRevision(source, revision_id)
596599
597 push_result = GitPushResult()600 push_result = GitPushResult()
598 push_result.workingtree_updated = None601 push_result.workingtree_updated = None
@@ -645,6 +648,9 @@
645 new_sha = repo.lookup_bzr_revision_id(revid)[0]648 new_sha = repo.lookup_bzr_revision_id(revid)[0]
646 except errors.NoSuchRevision:649 except errors.NoSuchRevision:
647 continue650 continue
651 else:
652 if not source.repository.has_revision(revid):
653 continue
648 ret[tag_name_to_ref(tagname)] = new_sha654 ret[tag_name_to_ref(tagname)] = new_sha
649 return ret655 return ret
650 with source_store.lock_read():656 with source_store.lock_read():
651657
=== modified file 'breezy/tests/per_controldir/test_push.py'
--- breezy/tests/per_controldir/test_push.py 2020-02-19 04:50:09 +0000
+++ breezy/tests/per_controldir/test_push.py 2020-06-25 00:07:00 +0000
@@ -19,6 +19,7 @@
19from ...errors import (19from ...errors import (
20 LossyPushToSameVCS,20 LossyPushToSameVCS,
21 TagsNotSupported,21 TagsNotSupported,
22 NoSuchRevision,
22 )23 )
23from ...revision import NULL_REVISION24from ...revision import NULL_REVISION
24from .. import TestNotApplicable25from .. import TestNotApplicable
@@ -46,6 +47,13 @@
46 self.assertEqual(dir.open_branch().base,47 self.assertEqual(dir.open_branch().base,
47 tree.branch.get_push_location())48 tree.branch.get_push_location())
4849
50 def test_push_no_such_revision(self):
51 tree, rev_1 = self.create_simple_tree()
52 dir = self.make_repository('dir').controldir
53 self.assertRaises(
54 NoSuchRevision, dir.push_branch,
55 tree.branch, revision_id=b'idonotexist')
56
49 def test_push_new_branch_fetch_tags(self):57 def test_push_new_branch_fetch_tags(self):
50 builder = self.make_branch_builder('from')58 builder = self.make_branch_builder('from')
51 builder.start_series()59 builder.start_series()

Subscribers

People subscribed via source and target branches