Merge lp:~cjwatson/launchpad/fix-snap-initial-name-bzr into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18717
Proposed branch: lp:~cjwatson/launchpad/fix-snap-initial-name-bzr
Merge into: lp:launchpad
Diff against target: 114 lines (+14/-15)
2 files modified
lib/lp/code/model/branch.py (+2/-3)
lib/lp/code/model/tests/test_branch.py (+12/-12)
To merge this branch: bzr merge lp:~cjwatson/launchpad/fix-snap-initial-name-bzr
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Launchpad code reviewers Pending
Review via email: mp+349170@code.launchpad.net

Commit message

Fix Branch.getBlob to call the hosting client with branch IDs rather than unique names.

Description of the change

During review of https://code.launchpad.net/~cjwatson/launchpad/branch-hosting-client/+merge/345704, I changed BranchHostingClient to take branch IDs rather than unique names, but I forgot to update https://code.launchpad.net/~cjwatson/launchpad/snap-initial-name-bzr/+merge/345757 to match. This fixes that up.

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/branch.py'
2--- lib/lp/code/model/branch.py 2018-07-04 08:56:37 +0000
3+++ lib/lp/code/model/branch.py 2018-07-09 09:40:24 +0000
4@@ -829,7 +829,7 @@
5 if file_list is unset:
6 try:
7 inventory = hosting_client.getInventory(
8- self.unique_name, dirname, rev=revision_id)
9+ self.id, dirname, rev=revision_id)
10 file_list = {
11 entry['filename']: entry['file_id']
12 for entry in inventory['filelist']}
13@@ -843,8 +843,7 @@
14 if file_id is None:
15 raise BranchFileNotFound(
16 self.unique_name, filename=filename, rev=revision_id)
17- return hosting_client.getBlob(
18- self.unique_name, file_id, rev=revision_id)
19+ return hosting_client.getBlob(self.id, file_id, rev=revision_id)
20
21 def getDiff(self, new, old=None):
22 """See `IBranch`."""
23
24=== modified file 'lib/lp/code/model/tests/test_branch.py'
25--- lib/lp/code/model/tests/test_branch.py 2018-05-17 14:10:29 +0000
26+++ lib/lp/code/model/tests/test_branch.py 2018-07-09 09:40:24 +0000
27@@ -3311,10 +3311,10 @@
28 blob = branch.getBlob('src/README.txt')
29 self.assertEqual('Some text', blob)
30 self.assertEqual(
31- [((branch.unique_name, 'src'), {'rev': None})],
32+ [((branch.id, 'src'), {'rev': None})],
33 hosting_fixture.getInventory.calls)
34 self.assertEqual(
35- [((branch.unique_name, 'some-file-id'), {'rev': None})],
36+ [((branch.id, 'some-file-id'), {'rev': None})],
37 hosting_fixture.getBlob.calls)
38 self.assertEqual({}, getUtility(IMemcacheClient)._cache)
39
40@@ -3326,10 +3326,10 @@
41 blob = branch.getBlob('src/README.txt')
42 self.assertEqual('Some text', blob)
43 self.assertEqual(
44- [((branch.unique_name, 'src'), {'rev': 'scanned-id'})],
45+ [((branch.id, 'src'), {'rev': 'scanned-id'})],
46 hosting_fixture.getInventory.calls)
47 self.assertEqual(
48- [((branch.unique_name, 'some-file-id'), {'rev': 'scanned-id'})],
49+ [((branch.id, 'some-file-id'), {'rev': 'scanned-id'})],
50 hosting_fixture.getBlob.calls)
51 key = (
52 'bazaar.launchpad.dev:bzr-file-list:%s:scanned-id:src' % branch.id)
53@@ -3344,10 +3344,10 @@
54 blob = branch.getBlob('src/README.txt', revision_id='some-rev')
55 self.assertEqual('Some text', blob)
56 self.assertEqual(
57- [((branch.unique_name, 'src'), {'rev': 'some-rev'})],
58+ [((branch.id, 'src'), {'rev': 'some-rev'})],
59 hosting_fixture.getInventory.calls)
60 self.assertEqual(
61- [((branch.unique_name, 'some-file-id'), {'rev': 'some-rev'})],
62+ [((branch.id, 'some-file-id'), {'rev': 'some-rev'})],
63 hosting_fixture.getBlob.calls)
64 key = 'bazaar.launchpad.dev:bzr-file-list:%s:some-rev:src' % branch.id
65 self.assertEqual(
66@@ -3365,7 +3365,7 @@
67 self.assertEqual('Some text', blob)
68 self.assertEqual([], hosting_fixture.getInventory.calls)
69 self.assertEqual(
70- [((branch.unique_name, 'some-file-id'), {'rev': 'some-rev'})],
71+ [((branch.id, 'some-file-id'), {'rev': 'some-rev'})],
72 hosting_fixture.getBlob.calls)
73
74 def test_disable_memcache(self):
75@@ -3379,7 +3379,7 @@
76 blob = branch.getBlob('src/README.txt', revision_id='some-rev')
77 self.assertEqual('Some text', blob)
78 self.assertEqual(
79- [((branch.unique_name, 'src'), {'rev': 'some-rev'})],
80+ [((branch.id, 'src'), {'rev': 'some-rev'})],
81 hosting_fixture.getInventory.calls)
82 self.assertEqual(
83 '{}', getUtility(IMemcacheClient).get(key.encode('UTF-8')))
84@@ -3391,10 +3391,10 @@
85 blob = branch.getBlob('README.txt', revision_id='some-rev')
86 self.assertEqual('Some text', blob)
87 self.assertEqual(
88- [((branch.unique_name, ''), {'rev': 'some-rev'})],
89+ [((branch.id, ''), {'rev': 'some-rev'})],
90 hosting_fixture.getInventory.calls)
91 self.assertEqual(
92- [((branch.unique_name, 'some-file-id'), {'rev': 'some-rev'})],
93+ [((branch.id, 'some-file-id'), {'rev': 'some-rev'})],
94 hosting_fixture.getBlob.calls)
95 key = 'bazaar.launchpad.dev:bzr-file-list:%s:some-rev:' % branch.id
96 self.assertEqual(
97@@ -3408,7 +3408,7 @@
98 BranchFileNotFound, branch.getBlob,
99 'src/README.txt', revision_id='some-rev')
100 self.assertEqual(
101- [((branch.unique_name, 'src'), {'rev': 'some-rev'})],
102+ [((branch.id, 'src'), {'rev': 'some-rev'})],
103 hosting_fixture.getInventory.calls)
104 self.assertEqual([], hosting_fixture.getBlob.calls)
105 key = 'bazaar.launchpad.dev:bzr-file-list:%s:some-rev:src' % branch.id
106@@ -3425,7 +3425,7 @@
107 BranchFileNotFound, branch.getBlob,
108 'src/README.txt', revision_id='some-rev')
109 self.assertEqual(
110- [((branch.unique_name, 'src'), {'rev': 'some-rev'})],
111+ [((branch.id, 'src'), {'rev': 'some-rev'})],
112 hosting_fixture.getInventory.calls)
113 self.assertEqual([], hosting_fixture.getBlob.calls)
114 key = 'bazaar.launchpad.dev:bzr-file-list:%s:some-rev:src' % branch.id