Merge lp:~jelmer/brz/ref-is-dir into lp:brz/3.0

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/ref-is-dir
Merge into: lp:brz/3.0
Diff against target: 54 lines (+16/-3)
3 files modified
breezy/git/tests/test_dir.py (+8/-2)
breezy/git/transportgit.py (+5/-1)
doc/en/release-notes/brz-3.0.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/ref-is-dir
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+375941@code.launchpad.net

Commit message

Don't throw an error attempting to read the parent of a ref.

Description of the change

Don't throw an error attempting to read the parent of a ref.

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 :
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/tests/test_dir.py'
2--- breezy/git/tests/test_dir.py 2018-11-11 04:08:32 +0000
3+++ breezy/git/tests/test_dir.py 2019-12-23 03:05:34 +0000
4@@ -53,11 +53,17 @@
5 gd = controldir.ControlDir.open('.')
6 self.assertIsInstance(gd, dir.LocalGitDir)
7
8+ def test_open_ref_parent(self):
9+ r = GitRepo.init(".")
10+ cid = r.do_commit(message=b"message", ref=b'refs/heads/foo/bar')
11+ gd = controldir.ControlDir.open('.')
12+ self.assertRaises(errors.NotBranchError, gd.open_branch, 'foo')
13+
14 def test_open_workingtree(self):
15- GitRepo.init(".")
16+ r = GitRepo.init(".")
17+ r.do_commit(message=b"message")
18
19 gd = controldir.ControlDir.open('.')
20- raise TestSkipped
21 wt = gd.open_workingtree()
22 self.assertIsInstance(wt, workingtree.GitWorkingTree)
23
24
25=== modified file 'breezy/git/transportgit.py'
26--- breezy/git/transportgit.py 2019-02-06 05:44:37 +0000
27+++ breezy/git/transportgit.py 2019-12-23 03:05:34 +0000
28@@ -211,7 +211,11 @@
29 except NoSuchFile:
30 return None
31 with f:
32- header = f.read(len(SYMREF))
33+ try:
34+ header = f.read(len(SYMREF))
35+ except ReadError:
36+ # probably a directory
37+ return None
38 if header == SYMREF:
39 # Read only the first line
40 return header + next(iter(f)).rstrip(b"\r\n")
41
42=== modified file 'doc/en/release-notes/brz-3.0.txt'
43--- doc/en/release-notes/brz-3.0.txt 2019-12-23 00:25:21 +0000
44+++ doc/en/release-notes/brz-3.0.txt 2019-12-23 03:05:34 +0000
45@@ -32,6 +32,9 @@
46 .. Fixes for situations where brz would previously crash or give incorrect
47 or undesirable results.
48
49+ * Don't throw an error attempting to read the parent of a ref.
50+ (Jelmer Vernooij)
51+
52 * Fix fast-exporting of symlinks on Python 3. (Jelmer Vernooij, #1851478)
53
54 * Don't rely on private transport attribute in fast-import.

Subscribers

People subscribed via source and target branches