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
1=== modified file 'breezy/git/remote.py'
2--- breezy/git/remote.py 2020-06-21 22:11:03 +0000
3+++ breezy/git/remote.py 2020-06-25 00:07:00 +0000
4@@ -593,6 +593,9 @@
5 # No revision supplied by the user, default to the branch
6 # revision
7 revision_id = source.last_revision()
8+ else:
9+ if not source.repository.has_revision(revision_id):
10+ raise NoSuchRevision(source, revision_id)
11
12 push_result = GitPushResult()
13 push_result.workingtree_updated = None
14@@ -645,6 +648,9 @@
15 new_sha = repo.lookup_bzr_revision_id(revid)[0]
16 except errors.NoSuchRevision:
17 continue
18+ else:
19+ if not source.repository.has_revision(revid):
20+ continue
21 ret[tag_name_to_ref(tagname)] = new_sha
22 return ret
23 with source_store.lock_read():
24
25=== modified file 'breezy/tests/per_controldir/test_push.py'
26--- breezy/tests/per_controldir/test_push.py 2020-02-19 04:50:09 +0000
27+++ breezy/tests/per_controldir/test_push.py 2020-06-25 00:07:00 +0000
28@@ -19,6 +19,7 @@
29 from ...errors import (
30 LossyPushToSameVCS,
31 TagsNotSupported,
32+ NoSuchRevision,
33 )
34 from ...revision import NULL_REVISION
35 from .. import TestNotApplicable
36@@ -46,6 +47,13 @@
37 self.assertEqual(dir.open_branch().base,
38 tree.branch.get_push_location())
39
40+ def test_push_no_such_revision(self):
41+ tree, rev_1 = self.create_simple_tree()
42+ dir = self.make_repository('dir').controldir
43+ self.assertRaises(
44+ NoSuchRevision, dir.push_branch,
45+ tree.branch, revision_id=b'idonotexist')
46+
47 def test_push_new_branch_fetch_tags(self):
48 builder = self.make_branch_builder('from')
49 builder.start_series()

Subscribers

People subscribed via source and target branches