Merge lp:~jelmer/brz/simplify-remote-git into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7614
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/simplify-remote-git
Merge into: lp:brz
Diff against target: 94 lines (+6/-33)
2 files modified
breezy/git/errors.py (+0/-19)
breezy/git/remote.py (+6/-14)
To merge this branch: bzr merge lp:~jelmer/brz/simplify-remote-git
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+426998@code.launchpad.net

Commit message

Simplify remote git branch handling.

Description of the change

Simplify remote git branch handling.

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 :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
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/errors.py'
2--- breezy/git/errors.py 2020-02-18 01:57:45 +0000
3+++ breezy/git/errors.py 2022-08-29 10:50:44 +0000
4@@ -26,25 +26,6 @@
5 """The base-level exception for bzr-git errors."""
6
7
8-class NoSuchRef(BzrGitError):
9- """Raised when a ref can not be found."""
10-
11- _fmt = "The ref %(ref)s was not found in the repository at %(location)s."
12-
13- def __init__(self, ref, location, present_refs=None):
14- self.ref = ref
15- self.location = location
16- self.present_refs = present_refs
17-
18-
19-def convert_dulwich_error(error):
20- """Convert a Dulwich error to a Bazaar error."""
21-
22- if isinstance(error, git_errors.HangupException):
23- raise brz_errors.ConnectionReset(error.msg, "")
24- raise error
25-
26-
27 class NoPushSupport(brz_errors.BzrError):
28 _fmt = ("Push is not yet supported from %(source)r to %(target)r "
29 "using %(mapping)r for %(revision_id)r. Try dpush instead.")
30
31=== modified file 'breezy/git/remote.py'
32--- breezy/git/remote.py 2022-08-28 19:41:33 +0000
33+++ breezy/git/remote.py 2022-08-29 10:50:44 +0000
34@@ -80,7 +80,6 @@
35 )
36 from .errors import (
37 GitSmartRemoteNotSupported,
38- NoSuchRef,
39 )
40 from .mapping import (
41 encode_git_path,
42@@ -538,12 +537,12 @@
43 refname = self._get_selected_ref(name, ref)
44 if refname != b'HEAD' and refname in self.get_refs_container():
45 raise AlreadyBranchError(self.user_url)
46- ref_chain, unused_sha = self.get_refs_container().follow(
47+ ref_chain, sha = self.get_refs_container().follow(
48 self._get_selected_ref(name))
49 if ref_chain and ref_chain[0] == b'HEAD' and len(ref_chain) > 1:
50 refname = ref_chain[1]
51 repo = self.open_repository()
52- return RemoteGitBranch(self, repo, refname)
53+ return RemoteGitBranch(self, repo, refname, sha)
54
55 def destroy_branch(self, name=None):
56 refname = self._get_selected_ref(name)
57@@ -601,10 +600,10 @@
58 raise NotBranchError(self.root_transport.base,
59 controldir=self)
60 try:
61- ref_chain, unused_sha = self.get_refs_container().follow(ref)
62+ ref_chain, sha = self.get_refs_container().follow(ref)
63 except SymrefLoop:
64 raise BranchReferenceLoop(self)
65- return RemoteGitBranch(self, repo, ref_chain[-1])
66+ return RemoteGitBranch(self, repo, ref_chain[-1], sha)
67
68 def open_workingtree(self, recommend_upgrade=False):
69 raise NotLocalUrl(self.transport.base)
70@@ -1045,8 +1044,8 @@
71
72 class RemoteGitBranch(GitBranch):
73
74- def __init__(self, controldir, repository, ref):
75- self._sha = None
76+ def __init__(self, controldir, repository, ref, sha):
77+ self._sha = sha
78 super(RemoteGitBranch, self).__init__(controldir, repository, ref,
79 RemoteGitBranchFormat())
80
81@@ -1069,13 +1068,6 @@
82
83 @property
84 def head(self):
85- if self._sha is not None:
86- return self._sha
87- refs = self.controldir.get_refs_container()
88- try:
89- self._sha = refs[self.ref]
90- except KeyError:
91- raise NoSuchRef(self.ref, self.repository.user_url, refs)
92 return self._sha
93
94 def _synchronize_history(self, destination, revision_id):

Subscribers

People subscribed via source and target branches