Merge lp:~jelmer/brz/alpha-fix-git-python3 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/alpha-fix-git-python3
Merge into: lp:brz
Diff against target: 61 lines (+24/-7)
2 files modified
breezy/git/tests/test_transportgit.py (+23/-6)
breezy/git/transportgit.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/alpha-fix-git-python3
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+356037@code.launchpad.net

Commit message

Fix reading of packed refs on Python 3.

Description of the change

Fix reading of packed refs on Python 3.

Breezy itself never creates packed-refs, so this codepath was not exercised.

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

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/511/

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-04 17:14:51 +0000
4@@ -20,11 +20,15 @@
5
6 from dulwich.objects import Blob
7 from dulwich.tests.test_object_store import PackBasedObjectStoreTests
8+from dulwich.tests.test_refs import RefsContainerTests
9 from dulwich.tests.utils import make_object
10
11 from ...tests import TestCaseWithTransport
12
13-from ..transportgit import TransportObjectStore
14+from ..transportgit import (
15+ TransportObjectStore,
16+ TransportRefsContainer,
17+ )
18
19
20 class TransportObjectStoreTests(PackBasedObjectStoreTests, TestCaseWithTransport):
21@@ -55,9 +59,22 @@
22
23 # FIXME: Unfortunately RefsContainerTests requires on a specific set of refs existing.
24
25-# class TransportRefContainerTests(RefsContainerTests, TestCaseWithTransport):
26-#
27-# def setUp(self):
28-# TestCaseWithTransport.setUp(self)
29-# self._refs = TransportRefsContainer(self.get_transport())
30+class TransportRefContainerTests(TestCaseWithTransport):
31+
32+ def setUp(self):
33+ TestCaseWithTransport.setUp(self)
34+ self._refs = TransportRefsContainer(self.get_transport())
35+
36+ def test_packed_refs_missing(self):
37+ self.assertEqual({}, self._refs.get_packed_refs())
38+
39+ def test_packed_refs(self):
40+ self.get_transport().put_bytes_non_atomic('packed-refs',
41+ b'# pack-refs with: peeled fully-peeled sorted \n'
42+ b'2001b954f1ec392f84f7cec2f2f96a76ed6ba4ee refs/heads/master')
43+ self.assertEqual(
44+ {b'refs/heads/master': b'2001b954f1ec392f84f7cec2f2f96a76ed6ba4ee'},
45+ self._refs.get_packed_refs())
46+
47+
48
49
50=== modified file 'breezy/git/transportgit.py'
51--- breezy/git/transportgit.py 2018-08-04 17:32:58 +0000
52+++ breezy/git/transportgit.py 2018-10-04 17:14:51 +0000
53@@ -164,7 +164,7 @@
54 return {}
55 try:
56 first_line = next(iter(f)).rstrip()
57- if (first_line.startswith("# pack-refs") and " peeled" in
58+ if (first_line.startswith(b"# pack-refs") and b" peeled" in
59 first_line):
60 for sha, name, peeled in read_packed_refs_with_peeled(f):
61 self._packed_refs[name] = sha

Subscribers

People subscribed via source and target branches