Merge lp:~jelmer/brz/packs-file into lp:brz

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/packs-file
Merge into: lp:brz
Diff against target: 71 lines (+28/-14)
2 files modified
breezy/git/tests/test_transportgit.py (+13/-0)
breezy/git/transportgit.py (+15/-14)
To merge this branch: bzr merge lp:~jelmer/brz/packs-file
Reviewer Review Type Date Requested Status
Martin Packman Approve
Jelmer Vernooij Approve
Review via email: mp+356198@code.launchpad.net

Commit message

Only read the .git/objects/info/packs file if the packs file isn't listable.

Description of the change

Only read the .git/objects/info/packs file if the packs file isn't listable.

This avoids reading outdated packs files.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Martin Packman (gz) wrote :

Looks reasonable, thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/507/

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/509/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tests/test_transportgit.py'
2--- breezy/git/tests/test_transportgit.py 2018-06-14 17:59:16 +0000
3+++ breezy/git/tests/test_transportgit.py 2018-10-13 13:21:19 +0000
4@@ -37,6 +37,19 @@
5 PackBasedObjectStoreTests.tearDown(self)
6 TestCaseWithTransport.tearDown(self)
7
8+ def test_prefers_pack_listdir(self):
9+ self.store.add_object(make_object(Blob, data=b"data"))
10+ self.assertEqual(0, len(self.store.packs))
11+ self.store.pack_loose_objects()
12+ self.assertEqual(1, len(self.store.packs))
13+ packname = list(self.store.packs)[0].name()
14+ self.assertEqual({'pack-%s.pack' % packname.decode('ascii'), 'pack-%s.idx' % packname.decode('ascii')},
15+ set(self.store._pack_names()))
16+ self.store.transport.put_bytes_non_atomic('info/packs',
17+ b'P foo-pack.pack\n')
18+ self.assertEqual({'pack-%s.pack' % packname.decode('ascii'), 'pack-%s.idx' % packname.decode('ascii')},
19+ set(self.store._pack_names()))
20+
21 def test_remembers_packs(self):
22 self.store.add_object(make_object(Blob, data=b"data"))
23 self.assertEqual(0, len(self.store.packs))
24
25=== modified file 'breezy/git/transportgit.py'
26--- breezy/git/transportgit.py 2018-08-04 17:32:58 +0000
27+++ breezy/git/transportgit.py 2018-10-13 13:21:19 +0000
28@@ -164,7 +164,7 @@
29 return {}
30 try:
31 first_line = next(iter(f)).rstrip()
32- if (first_line.startswith("# pack-refs") and " peeled" in
33+ if (first_line.startswith(b"# pack-refs") and b" peeled" in
34 first_line):
35 for sha, name, peeled in read_packed_refs_with_peeled(f):
36 self._packed_refs[name] = sha
37@@ -600,20 +600,21 @@
38
39 def _pack_names(self):
40 try:
41- f = self.transport.get('info/packs')
42- except NoSuchFile:
43 return self.pack_transport.list_dir(".")
44- else:
45- with f:
46- ret = []
47- for line in f.read().splitlines():
48- if not line:
49- continue
50- (kind, name) = line.split(b" ", 1)
51- if kind != b"P":
52- continue
53- ret.append(name)
54- return ret
55+ except TransportNotPossible:
56+ try:
57+ f = self.transport.get('info/packs')
58+ except NoSuchFile:
59+ # Hmm, warn about running 'git update-server-info' ?
60+ return iter([])
61+ else:
62+ # TODO(jelmer): Move to top-level after dulwich
63+ # 0.19.7 is released.
64+ from dulwich.object_store import read_packs_file
65+ with f:
66+ return read_packs_file(f)
67+ except NoSuchFile:
68+ return iter([])
69
70 def _remove_pack(self, pack):
71 self.pack_transport.delete(os.path.basename(pack.index.path))

Subscribers

People subscribed via source and target branches