Merge lp:~jelmer/brz/git-present-only 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/git-present-only
Merge into: lp:brz
Diff against target: 118 lines (+33/-36)
2 files modified
breezy/git/branch.py (+30/-36)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/git-present-only
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+377144@code.launchpad.net

Commit message

Ignore ghost tags when interacting with remote Git repositories.

Description of the change

Ignore ghost tags when interacting with remote Git repositories.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/branch.py'
2--- breezy/git/branch.py 2019-10-20 02:08:44 +0000
3+++ breezy/git/branch.py 2020-01-02 11:41:46 +0000
4@@ -30,6 +30,7 @@
5
6 from .. import (
7 branch,
8+ cleanup,
9 config,
10 controldir,
11 errors,
12@@ -235,9 +236,9 @@
13 master = None
14 else:
15 master = to_tags.branch.get_master_branch()
16- if master is not None:
17- master.lock_write()
18- try:
19+ with cleanup.ExitStack() as es:
20+ if master is not None:
21+ es.enter_context(master.lock_write())
22 updates, conflicts = self._merge_to_non_git(
23 to_tags, source_tag_refs, overwrite=overwrite)
24 if master is not None:
25@@ -248,9 +249,6 @@
26 updates.update(extra_updates)
27 conflicts += extra_conflicts
28 return updates, conflicts
29- finally:
30- if master is not None:
31- master.unlock()
32
33 def get_tag_dict(self):
34 ret = {}
35@@ -1038,37 +1036,30 @@
36 bound_location = self.target.get_bound_location()
37 if local and not bound_location:
38 raise errors.LocalRequiresBoundBranch()
39- master_branch = None
40 source_is_master = False
41- self.source.lock_read()
42- if bound_location:
43- # bound_location comes from a config file, some care has to be
44- # taken to relate it to source.user_url
45- normalized = urlutils.normalize_url(bound_location)
46- try:
47- relpath = self.source.user_transport.relpath(normalized)
48- source_is_master = (relpath == '')
49- except (errors.PathNotChild, urlutils.InvalidURL):
50- source_is_master = False
51- if not local and bound_location and not source_is_master:
52- # not pulling from master, so we need to update master.
53- master_branch = self.target.get_master_branch(possible_transports)
54- master_branch.lock_write()
55- try:
56- try:
57- if master_branch:
58- # pull from source into master.
59- master_branch.pull(self.source, overwrite, stop_revision,
60- run_hooks=False)
61- result = self._basic_pull(stop_revision, overwrite, run_hooks,
62- _override_hook_target,
63- _hook_master=master_branch)
64- finally:
65- self.source.unlock()
66- finally:
67- if master_branch:
68- master_branch.unlock()
69- return result
70+ with cleanup.ExitStack() as es:
71+ es.enter_context(self.source.lock_read())
72+ if bound_location:
73+ # bound_location comes from a config file, some care has to be
74+ # taken to relate it to source.user_url
75+ normalized = urlutils.normalize_url(bound_location)
76+ try:
77+ relpath = self.source.user_transport.relpath(normalized)
78+ source_is_master = (relpath == '')
79+ except (errors.PathNotChild, urlutils.InvalidURL):
80+ source_is_master = False
81+ if not local and bound_location and not source_is_master:
82+ # not pulling from master, so we need to update master.
83+ master_branch = self.target.get_master_branch(possible_transports)
84+ es.enter_context(master_branch.lock_write())
85+ # pull from source into master.
86+ master_branch.pull(self.source, overwrite, stop_revision,
87+ run_hooks=False)
88+ else:
89+ master_branch = None
90+ return self._basic_pull(stop_revision, overwrite, run_hooks,
91+ _override_hook_target,
92+ _hook_master=master_branch)
93
94 def _basic_push(self, overwrite, stop_revision):
95 if overwrite is True:
96@@ -1135,6 +1126,9 @@
97 result.new_revid = stop_revision
98 for name, sha in viewitems(
99 self.source.repository._git.refs.as_dict(b"refs/tags")):
100+ if sha not in self.source.repository._git:
101+ trace.mutter('Ignoring missing SHA: %s', sha)
102+ continue
103 refs[tag_name_to_ref(name)] = sha
104 return refs
105 self.target.repository.send_pack(
106
107=== modified file 'doc/en/release-notes/brz-3.1.txt'
108--- doc/en/release-notes/brz-3.1.txt 2019-12-23 11:22:51 +0000
109+++ doc/en/release-notes/brz-3.1.txt 2020-01-02 11:41:46 +0000
110@@ -120,6 +120,9 @@
111 * Fix ``brz diff --using`` when {old_path} and {new_path} are not
112 specified in the template. (#1847915, Jelmer Vernooij)
113
114+* Ignore ghost tags when interacting with remote Git repositories.
115+ (Jelmer Vernooij)
116+
117 Documentation
118 *************
119

Subscribers

People subscribed via source and target branches