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
=== modified file 'breezy/git/errors.py'
--- breezy/git/errors.py 2020-02-18 01:57:45 +0000
+++ breezy/git/errors.py 2022-08-29 10:50:44 +0000
@@ -26,25 +26,6 @@
26 """The base-level exception for bzr-git errors."""26 """The base-level exception for bzr-git errors."""
2727
2828
29class NoSuchRef(BzrGitError):
30 """Raised when a ref can not be found."""
31
32 _fmt = "The ref %(ref)s was not found in the repository at %(location)s."
33
34 def __init__(self, ref, location, present_refs=None):
35 self.ref = ref
36 self.location = location
37 self.present_refs = present_refs
38
39
40def convert_dulwich_error(error):
41 """Convert a Dulwich error to a Bazaar error."""
42
43 if isinstance(error, git_errors.HangupException):
44 raise brz_errors.ConnectionReset(error.msg, "")
45 raise error
46
47
48class NoPushSupport(brz_errors.BzrError):29class NoPushSupport(brz_errors.BzrError):
49 _fmt = ("Push is not yet supported from %(source)r to %(target)r "30 _fmt = ("Push is not yet supported from %(source)r to %(target)r "
50 "using %(mapping)r for %(revision_id)r. Try dpush instead.")31 "using %(mapping)r for %(revision_id)r. Try dpush instead.")
5132
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2022-08-28 19:41:33 +0000
+++ breezy/git/remote.py 2022-08-29 10:50:44 +0000
@@ -80,7 +80,6 @@
80 )80 )
81from .errors import (81from .errors import (
82 GitSmartRemoteNotSupported,82 GitSmartRemoteNotSupported,
83 NoSuchRef,
84 )83 )
85from .mapping import (84from .mapping import (
86 encode_git_path,85 encode_git_path,
@@ -538,12 +537,12 @@
538 refname = self._get_selected_ref(name, ref)537 refname = self._get_selected_ref(name, ref)
539 if refname != b'HEAD' and refname in self.get_refs_container():538 if refname != b'HEAD' and refname in self.get_refs_container():
540 raise AlreadyBranchError(self.user_url)539 raise AlreadyBranchError(self.user_url)
541 ref_chain, unused_sha = self.get_refs_container().follow(540 ref_chain, sha = self.get_refs_container().follow(
542 self._get_selected_ref(name))541 self._get_selected_ref(name))
543 if ref_chain and ref_chain[0] == b'HEAD' and len(ref_chain) > 1:542 if ref_chain and ref_chain[0] == b'HEAD' and len(ref_chain) > 1:
544 refname = ref_chain[1]543 refname = ref_chain[1]
545 repo = self.open_repository()544 repo = self.open_repository()
546 return RemoteGitBranch(self, repo, refname)545 return RemoteGitBranch(self, repo, refname, sha)
547546
548 def destroy_branch(self, name=None):547 def destroy_branch(self, name=None):
549 refname = self._get_selected_ref(name)548 refname = self._get_selected_ref(name)
@@ -601,10 +600,10 @@
601 raise NotBranchError(self.root_transport.base,600 raise NotBranchError(self.root_transport.base,
602 controldir=self)601 controldir=self)
603 try:602 try:
604 ref_chain, unused_sha = self.get_refs_container().follow(ref)603 ref_chain, sha = self.get_refs_container().follow(ref)
605 except SymrefLoop:604 except SymrefLoop:
606 raise BranchReferenceLoop(self)605 raise BranchReferenceLoop(self)
607 return RemoteGitBranch(self, repo, ref_chain[-1])606 return RemoteGitBranch(self, repo, ref_chain[-1], sha)
608607
609 def open_workingtree(self, recommend_upgrade=False):608 def open_workingtree(self, recommend_upgrade=False):
610 raise NotLocalUrl(self.transport.base)609 raise NotLocalUrl(self.transport.base)
@@ -1045,8 +1044,8 @@
10451044
1046class RemoteGitBranch(GitBranch):1045class RemoteGitBranch(GitBranch):
10471046
1048 def __init__(self, controldir, repository, ref):1047 def __init__(self, controldir, repository, ref, sha):
1049 self._sha = None1048 self._sha = sha
1050 super(RemoteGitBranch, self).__init__(controldir, repository, ref,1049 super(RemoteGitBranch, self).__init__(controldir, repository, ref,
1051 RemoteGitBranchFormat())1050 RemoteGitBranchFormat())
10521051
@@ -1069,13 +1068,6 @@
10691068
1070 @property1069 @property
1071 def head(self):1070 def head(self):
1072 if self._sha is not None:
1073 return self._sha
1074 refs = self.controldir.get_refs_container()
1075 try:
1076 self._sha = refs[self.ref]
1077 except KeyError:
1078 raise NoSuchRef(self.ref, self.repository.user_url, refs)
1079 return self._sha1071 return self._sha
10801072
1081 def _synchronize_history(self, destination, revision_id):1073 def _synchronize_history(self, destination, revision_id):

Subscribers

People subscribed via source and target branches