bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.1613
by Jelmer Vernooij
Handle encoding better in working tree iter changes. |
1 |
# Copyright (C) 2007,2012 Canonical Ltd
|
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
2 |
# Copyright (C) 2009-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
17 |
|
18 |
"""An adapter between a Git Branch and a Bazaar Branch"""
|
|
19 |
||
|
0.200.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
20 |
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
21 |
import contextlib |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
22 |
from io import BytesIO |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
23 |
from collections import defaultdict |
24 |
||
|
7449.1.2
by Jelmer Vernooij
Fix git support. |
25 |
from dulwich.config import ( |
26 |
ConfigFile as GitConfigFile, |
|
27 |
parse_submodules, |
|
28 |
)
|
|
29 |
||
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
30 |
from dulwich.objects import ( |
|
0.200.1717
by Jelmer Vernooij
Ignore tags pointing at non-commit objects. |
31 |
NotCommitError, |
|
0.200.1153
by Jelmer Vernooij
Import ZERO_SHA from dulwich.objects. |
32 |
ZERO_SHA, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
33 |
)
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
34 |
from dulwich.repo import check_ref_format |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
35 |
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
36 |
from .. import ( |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
37 |
branch, |
38 |
config, |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
39 |
controldir, |
|
0.200.446
by Jelmer Vernooij
Support new 'local' argument. |
40 |
errors, |
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
41 |
lock, |
|
0.200.1097
by Jelmer Vernooij
Implement GitBranchFormat.initialize. |
42 |
repository as _mod_repository, |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
43 |
revision, |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
44 |
trace, |
|
0.230.1
by Jelmer Vernooij
Support lightweight checkouts. |
45 |
transport, |
|
0.200.1414
by Jelmer Vernooij
Fix pulling into bound branches. |
46 |
urlutils, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
47 |
)
|
|
6986.2.3
by Jelmer Vernooij
Merge trunk |
48 |
from ..foreign import ForeignBranch |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
49 |
from ..revision import ( |
|
0.200.969
by Jelmer Vernooij
Use tuples with bzr revid and git sha to avoid lookups. |
50 |
NULL_REVISION, |
51 |
)
|
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
52 |
from ..tag import ( |
53 |
Tags, |
|
54 |
InterTags, |
|
55 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
56 |
from ..trace import ( |
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
57 |
is_quiet, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
58 |
mutter, |
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
59 |
warning, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
60 |
)
|
61 |
||
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
62 |
from .errors import ( |
|
0.200.472
by Jelmer Vernooij
Fix printing error when user attempts to push into git. |
63 |
NoPushSupport, |
|
0.200.278
by Jelmer Vernooij
Update branch head appropriately during dpull. |
64 |
)
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
65 |
from .push import ( |
66 |
remote_divergence, |
|
67 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
68 |
from .refs import ( |
|
0.408.4
by Jelmer Vernooij
Fix some tests. |
69 |
branch_name_to_ref, |
|
0.200.1061
by Jelmer Vernooij
Add support for using unpeel map. |
70 |
is_tag, |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
71 |
ref_to_branch_name, |
|
0.200.1061
by Jelmer Vernooij
Add support for using unpeel map. |
72 |
ref_to_tag_name, |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
73 |
remote_refs_dict_to_tag_refs, |
|
0.200.875
by Jelmer Vernooij
Use new tag_name_to_ref function. |
74 |
tag_name_to_ref, |
|
0.200.1292
by Jelmer Vernooij
Fix repeeling objects when determining what to send. |
75 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
76 |
from .unpeel_map import ( |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
77 |
UnpeelMap, |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
78 |
)
|
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
79 |
from .urls import ( |
80 |
git_url_to_bzr_url, |
|
81 |
bzr_url_to_git_url, |
|
82 |
)
|
|
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
83 |
|
|
0.200.388
by Jelmer Vernooij
Support bzr 1.14 as well. |
84 |
|
|
7339.1.6
by Jelmer Vernooij
Also support revno-less push/pull operations. |
85 |
def _calculate_revnos(branch): |
86 |
if branch._format.stores_revno(): |
|
87 |
return True |
|
88 |
config = branch.get_config_stack() |
|
89 |
return config.get('calculate_revnos') |
|
90 |
||
91 |
||
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
92 |
class GitPullResult(branch.PullResult): |
|
0.200.956
by Jelmer Vernooij
Add some more format tests. |
93 |
"""Result of a pull from a Git branch.""" |
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
94 |
|
95 |
def _lookup_revno(self, revid): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
96 |
if not isinstance(revid, bytes): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
97 |
raise TypeError(revid) |
|
7339.1.6
by Jelmer Vernooij
Also support revno-less push/pull operations. |
98 |
if not _calculate_revnos(self.target_branch): |
99 |
return None |
|
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
100 |
# Try in source branch first, it'll be faster
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
101 |
with self.target_branch.lock_read(): |
|
0.200.1362
by Jelmer Vernooij
Add locking. |
102 |
return self.target_branch.revision_id_to_revno(revid) |
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
103 |
|
104 |
@property
|
|
105 |
def old_revno(self): |
|
106 |
return self._lookup_revno(self.old_revid) |
|
107 |
||
108 |
@property
|
|
109 |
def new_revno(self): |
|
110 |
return self._lookup_revno(self.new_revid) |
|
111 |
||
112 |
||
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
113 |
class InterTagsFromGitToRemoteGit(InterTags): |
114 |
||
115 |
@classmethod
|
|
116 |
def is_compatible(klass, source, target): |
|
117 |
if not isinstance(source, GitTags): |
|
118 |
return False |
|
119 |
if not isinstance(target, GitTags): |
|
120 |
return False |
|
121 |
if getattr(target.branch.repository, "_git", None) is not None: |
|
122 |
return False |
|
123 |
return True |
|
124 |
||
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
125 |
def merge(self, overwrite=False, ignore_master=False, selector=None): |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
126 |
if self.source.branch.repository.has_same_location(self.target.branch.repository): |
127 |
return {}, [] |
|
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
128 |
updates = {} |
129 |
conflicts = [] |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
130 |
source_tag_refs = self.source.branch.get_tag_refs() |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
131 |
ref_to_tag_map = {} |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
132 |
|
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
133 |
def get_changed_refs(old_refs): |
134 |
ret = dict(old_refs) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
135 |
for ref_name, tag_name, peeled, unpeeled in ( |
136 |
source_tag_refs.iteritems()): |
|
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
137 |
if selector and not selector(tag_name): |
138 |
continue
|
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
139 |
if old_refs.get(ref_name) == unpeeled: |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
140 |
pass
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
141 |
elif overwrite or ref_name not in old_refs: |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
142 |
ret[ref_name] = unpeeled |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
143 |
updates[tag_name] = self.target.branch.repository.lookup_foreign_revision_id( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
144 |
peeled) |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
145 |
ref_to_tag_map[ref_name] = tag_name |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
146 |
self.target.branch._tag_refs = None |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
147 |
else: |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
148 |
conflicts.append( |
149 |
(tag_name, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
150 |
self.repository.lookup_foreign_revision_id(peeled), |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
151 |
self.target.branch.repository.lookup_foreign_revision_id( |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
152 |
old_refs[ref_name]))) |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
153 |
return ret |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
154 |
result = self.target.branch.repository.controldir.send_pack( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
155 |
get_changed_refs, lambda have, want: []) |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
156 |
if result is not None and not isinstance(result, dict): |
157 |
for ref, error in result.ref_status.items(): |
|
158 |
if error: |
|
159 |
warning('unable to update ref %s: %s', |
|
160 |
ref, error) |
|
161 |
del updates[ref_to_tag_map[ref]] |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
162 |
return updates, set(conflicts) |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
163 |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
164 |
|
165 |
class InterTagsFromGitToLocalGit(InterTags): |
|
166 |
||
167 |
@classmethod
|
|
168 |
def is_compatible(klass, source, target): |
|
169 |
if not isinstance(source, GitTags): |
|
170 |
return False |
|
171 |
if not isinstance(target, GitTags): |
|
172 |
return False |
|
173 |
if getattr(target.branch.repository, "_git", None) is None: |
|
174 |
return False |
|
175 |
return True |
|
176 |
||
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
177 |
def merge(self, overwrite=False, ignore_master=False, selector=None): |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
178 |
if self.source.branch.repository.has_same_location(self.target.branch.repository): |
179 |
return {}, [] |
|
180 |
||
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
181 |
conflicts = [] |
182 |
updates = {} |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
183 |
source_tag_refs = self.source.branch.get_tag_refs() |
184 |
||
185 |
target_repo = self.target.branch.repository |
|
186 |
||
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
187 |
for ref_name, tag_name, peeled, unpeeled in source_tag_refs: |
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
188 |
if selector and not selector(tag_name): |
189 |
continue
|
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
190 |
if target_repo._git.refs.get(ref_name) == unpeeled: |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
191 |
pass
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
192 |
elif overwrite or ref_name not in target_repo._git.refs: |
|
7143.12.3
by Jelmer Vernooij
Ignore ghost tags. |
193 |
try: |
|
7143.15.8
by Jelmer Vernooij
Merge trunk. |
194 |
updates[tag_name] = ( |
|
7240.2.1
by Jelmer Vernooij
Don't copy tags that don't point to valid objects. |
195 |
target_repo.lookup_foreign_revision_id(peeled)) |
|
7143.12.3
by Jelmer Vernooij
Ignore ghost tags. |
196 |
except KeyError: |
197 |
trace.warning('%s does not point to a valid object', |
|
198 |
tag_name) |
|
|
7142.3.3
by Jelmer Vernooij
Fix test. |
199 |
continue
|
|
7405.1.1
by Jelmer Vernooij
Cope with non-commit tags in remote git repositories. |
200 |
except NotCommitError: |
201 |
trace.warning('%s points to a non-commit object', |
|
202 |
tag_name) |
|
203 |
continue
|
|
|
7240.2.1
by Jelmer Vernooij
Don't copy tags that don't point to valid objects. |
204 |
target_repo._git.refs[ref_name] = unpeeled or peeled |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
205 |
self.target.branch._tag_refs = None |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
206 |
else: |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
207 |
try: |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
208 |
source_revid = self.source.branch.repository.lookup_foreign_revision_id( |
|
7143.15.8
by Jelmer Vernooij
Merge trunk. |
209 |
peeled) |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
210 |
target_revid = target_repo.lookup_foreign_revision_id( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
211 |
target_repo._git.refs[ref_name]) |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
212 |
except KeyError: |
213 |
trace.warning('%s does not point to a valid object', |
|
214 |
ref_name) |
|
215 |
continue
|
|
|
7405.1.1
by Jelmer Vernooij
Cope with non-commit tags in remote git repositories. |
216 |
except NotCommitError: |
217 |
trace.warning('%s points to a non-commit object', |
|
218 |
tag_name) |
|
219 |
continue
|
|
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
220 |
conflicts.append((tag_name, source_revid, target_revid)) |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
221 |
return updates, set(conflicts) |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
222 |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
223 |
|
224 |
class InterTagsFromGitToNonGit(InterTags): |
|
225 |
||
226 |
@classmethod
|
|
227 |
def is_compatible(klass, source, target): |
|
228 |
if not isinstance(source, GitTags): |
|
229 |
return False |
|
230 |
if isinstance(target, GitTags): |
|
231 |
return False |
|
232 |
return True |
|
233 |
||
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
234 |
def merge(self, overwrite=False, ignore_master=False, selector=None): |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
235 |
"""See Tags.merge_to.""" |
236 |
source_tag_refs = self.source.branch.get_tag_refs() |
|
237 |
if ignore_master: |
|
238 |
master = None |
|
239 |
else: |
|
240 |
master = self.target.branch.get_master_branch() |
|
|
7494.1.1
by Jelmer Vernooij
merge lp:brz/3.1. |
241 |
with contextlib.ExitStack() as es: |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
242 |
if master is not None: |
243 |
es.enter_context(master.lock_write()) |
|
244 |
updates, conflicts = self._merge_to( |
|
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
245 |
self.target, source_tag_refs, overwrite=overwrite, |
246 |
selector=selector) |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
247 |
if master is not None: |
248 |
extra_updates, extra_conflicts = self._merge_to( |
|
249 |
master.tags, overwrite=overwrite, |
|
250 |
source_tag_refs=source_tag_refs, |
|
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
251 |
ignore_master=ignore_master, selector=selector) |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
252 |
updates.update(extra_updates) |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
253 |
conflicts.update(extra_conflicts) |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
254 |
return updates, conflicts |
255 |
||
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
256 |
def _merge_to(self, to_tags, source_tag_refs, overwrite=False, |
257 |
selector=None): |
|
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
258 |
unpeeled_map = defaultdict(set) |
259 |
conflicts = [] |
|
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
260 |
updates = {} |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
261 |
result = dict(to_tags.get_tag_dict()) |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
262 |
for ref_name, tag_name, peeled, unpeeled in source_tag_refs: |
|
7489.4.1
by Jelmer Vernooij
Add tag selecting callback. |
263 |
if selector and not selector(tag_name): |
264 |
continue
|
|
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
265 |
if unpeeled is not None: |
266 |
unpeeled_map[peeled].add(unpeeled) |
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
267 |
try: |
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
268 |
bzr_revid = self.source.branch.lookup_foreign_revision_id(peeled) |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
269 |
except NotCommitError: |
270 |
continue
|
|
271 |
if result.get(tag_name) == bzr_revid: |
|
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
272 |
pass
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
273 |
elif tag_name not in result or overwrite: |
274 |
result[tag_name] = bzr_revid |
|
275 |
updates[tag_name] = bzr_revid |
|
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
276 |
else: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
277 |
conflicts.append((tag_name, bzr_revid, result[tag_name])) |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
278 |
to_tags._set_tag_dict(result) |
279 |
if len(unpeeled_map) > 0: |
|
280 |
map_file = UnpeelMap.from_repository(to_tags.branch.repository) |
|
281 |
map_file.update(unpeeled_map) |
|
282 |
map_file.save_in_repository(to_tags.branch.repository) |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
283 |
return updates, set(conflicts) |
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
284 |
|
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
285 |
|
286 |
InterTags.register_optimiser(InterTagsFromGitToRemoteGit) |
|
287 |
InterTags.register_optimiser(InterTagsFromGitToLocalGit) |
|
288 |
InterTags.register_optimiser(InterTagsFromGitToNonGit) |
|
289 |
||
290 |
||
291 |
class GitTags(Tags): |
|
292 |
"""Ref-based tag dictionary.""" |
|
293 |
||
294 |
def __init__(self, branch): |
|
295 |
self.branch = branch |
|
296 |
self.repository = branch.repository |
|
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
297 |
|
298 |
def get_tag_dict(self): |
|
299 |
ret = {} |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
300 |
for (ref_name, tag_name, peeled, unpeeled) in ( |
301 |
self.branch.get_tag_refs()): |
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
302 |
try: |
303 |
bzr_revid = self.branch.lookup_foreign_revision_id(peeled) |
|
304 |
except NotCommitError: |
|
305 |
continue
|
|
306 |
else: |
|
307 |
ret[tag_name] = bzr_revid |
|
|
0.200.1065
by Jelmer Vernooij
Don't peel tags automatically when pushing back. |
308 |
return ret |
309 |
||
|
7489.3.2
by Jelmer Vernooij
Use InterTags in anger. |
310 |
def lookup_tag(self, tag_name): |
311 |
"""Return the referent string of a tag""" |
|
312 |
# TODO(jelmer): Replace with something more efficient for local tags.
|
|
313 |
td = self.get_tag_dict() |
|
314 |
try: |
|
315 |
return td[tag_name] |
|
316 |
except KeyError: |
|
317 |
raise errors.NoSuchTag(tag_name) |
|
318 |
||
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
319 |
|
320 |
class LocalGitTagDict(GitTags): |
|
321 |
"""Dictionary with tags in a local repository.""" |
|
322 |
||
323 |
def __init__(self, branch): |
|
324 |
super(LocalGitTagDict, self).__init__(branch) |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
325 |
self.refs = self.repository.controldir._git.refs |
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
326 |
|
|
0.200.711
by Jelmer Vernooij
Support merging tags to a local Git repository. |
327 |
def _set_tag_dict(self, to_dict): |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
328 |
extra = set(self.refs.allkeys()) |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
329 |
for k, revid in to_dict.items(): |
|
0.200.875
by Jelmer Vernooij
Use new tag_name_to_ref function. |
330 |
name = tag_name_to_ref(k) |
|
0.200.711
by Jelmer Vernooij
Support merging tags to a local Git repository. |
331 |
if name in extra: |
332 |
extra.remove(name) |
|
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
333 |
try: |
334 |
self.set_tag(k, revid) |
|
335 |
except errors.GhostTagsNotSupported: |
|
336 |
pass
|
|
|
0.200.711
by Jelmer Vernooij
Support merging tags to a local Git repository. |
337 |
for name in extra: |
|
0.200.1061
by Jelmer Vernooij
Add support for using unpeel map. |
338 |
if is_tag(name): |
|
0.200.711
by Jelmer Vernooij
Support merging tags to a local Git repository. |
339 |
del self.repository._git[name] |
|
0.200.956
by Jelmer Vernooij
Add some more format tests. |
340 |
|
|
0.200.86
by Jelmer Vernooij
Clearer error when setting tags. |
341 |
def set_tag(self, name, revid): |
|
0.200.1369
by Jelmer Vernooij
Clarify that ghost tags are not supported. |
342 |
try: |
343 |
git_sha, mapping = self.branch.lookup_bzr_revision_id(revid) |
|
344 |
except errors.NoSuchRevision: |
|
345 |
raise errors.GhostTagsNotSupported(self) |
|
346 |
self.refs[tag_name_to_ref(name)] = git_sha |
|
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
347 |
self.branch._tag_refs = None |
348 |
||
349 |
def delete_tag(self, name): |
|
350 |
ref = tag_name_to_ref(name) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
351 |
if ref not in self.refs: |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
352 |
raise errors.NoSuchTag(name) |
353 |
del self.refs[ref] |
|
354 |
self.branch._tag_refs = None |
|
|
0.239.1
by Jelmer Vernooij
Avoid re-connecting to fetch tags we already know. |
355 |
|
356 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
357 |
class GitBranchFormat(branch.BranchFormat): |
358 |
||
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
359 |
def network_name(self): |
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
360 |
return b"git" |
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
361 |
|
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
362 |
def supports_tags(self): |
363 |
return True |
|
364 |
||
|
0.200.1105
by Jelmer Vernooij
Don't claim to support leaving locks. |
365 |
def supports_leaving_lock(self): |
366 |
return False |
|
367 |
||
|
0.200.1369
by Jelmer Vernooij
Clarify that ghost tags are not supported. |
368 |
def supports_tags_referencing_ghosts(self): |
369 |
return False |
|
370 |
||
371 |
def tags_are_versioned(self): |
|
372 |
return False |
|
373 |
||
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
374 |
def get_foreign_tests_branch_factory(self): |
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
375 |
from .tests.test_branch import ForeignTestsBranchFactory |
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
376 |
return ForeignTestsBranchFactory() |
377 |
||
|
0.200.246
by Jelmer Vernooij
Cope with API changes in 1.13. |
378 |
def make_tags(self, branch): |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
379 |
try: |
380 |
return branch.tags |
|
381 |
except AttributeError: |
|
382 |
pass
|
|
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
383 |
if getattr(branch.repository, "_git", None) is None: |
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
384 |
from .remote import RemoteGitTagDict |
|
0.228.3
by Jelmer Vernooij
Fix tags when fetching from remotes. |
385 |
return RemoteGitTagDict(branch) |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
386 |
else: |
387 |
return LocalGitTagDict(branch) |
|
|
0.200.246
by Jelmer Vernooij
Cope with API changes in 1.13. |
388 |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
389 |
def initialize(self, a_controldir, name=None, repository=None, |
|
0.200.1378
by Jelmer Vernooij
Fix branch. |
390 |
append_revisions_only=None): |
|
0.295.2
by Jelmer Vernooij
Make RemoteGitBranchFormat uninitializeable. |
391 |
raise NotImplementedError(self.initialize) |
|
0.200.1097
by Jelmer Vernooij
Implement GitBranchFormat.initialize. |
392 |
|
|
0.200.1728
by Jelmer Vernooij
Support following branch references. |
393 |
def get_reference(self, controldir, name=None): |
|
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
394 |
return controldir.get_branch_reference(name=name) |
|
0.200.1728
by Jelmer Vernooij
Support following branch references. |
395 |
|
396 |
def set_reference(self, controldir, name, target): |
|
397 |
return controldir.set_branch_reference(target, name) |
|
398 |
||
|
7339.1.2
by Jelmer Vernooij
Add stores_revno method to BranchFormat. |
399 |
def stores_revno(self): |
400 |
"""True if this branch format store revision numbers.""" |
|
401 |
return False |
|
402 |
||
|
7449.2.4
by Jelmer Vernooij
Set BranchFormat.supports_reference_locations everywhere. |
403 |
supports_reference_locations = False |
404 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
405 |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
406 |
class LocalGitBranchFormat(GitBranchFormat): |
407 |
||
408 |
def get_format_description(self): |
|
409 |
return 'Local Git Branch' |
|
410 |
||
411 |
@property
|
|
412 |
def _matchingcontroldir(self): |
|
413 |
from .dir import LocalGitControlDirFormat |
|
414 |
return LocalGitControlDirFormat() |
|
415 |
||
|
0.295.2
by Jelmer Vernooij
Make RemoteGitBranchFormat uninitializeable. |
416 |
def initialize(self, a_controldir, name=None, repository=None, |
417 |
append_revisions_only=None): |
|
418 |
from .dir import LocalGitDir |
|
419 |
if not isinstance(a_controldir, LocalGitDir): |
|
420 |
raise errors.IncompatibleFormat(self, a_controldir._format) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
421 |
return a_controldir.create_branch( |
422 |
repository=repository, name=name, |
|
423 |
append_revisions_only=append_revisions_only) |
|
|
0.295.2
by Jelmer Vernooij
Make RemoteGitBranchFormat uninitializeable. |
424 |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
425 |
|
|
0.200.388
by Jelmer Vernooij
Support bzr 1.14 as well. |
426 |
class GitBranch(ForeignBranch): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
427 |
"""An adapter to git repositories for bzr Branch objects.""" |
428 |
||
|
0.200.1129
by Jelmer Vernooij
Implement GitBranch.control_transport. |
429 |
@property
|
430 |
def control_transport(self): |
|
|
0.310.16
by Jelmer Vernooij
Update xfail. |
431 |
return self._control_transport |
|
0.306.1
by Jelmer Vernooij
Set correct segment parameters on branches. |
432 |
|
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
433 |
@property
|
434 |
def user_transport(self): |
|
435 |
return self._user_transport |
|
436 |
||
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
437 |
def __init__(self, controldir, repository, ref, format): |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
438 |
self.repository = repository |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
439 |
self._format = format |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
440 |
self.controldir = controldir |
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
441 |
self._lock_mode = None |
442 |
self._lock_count = 0 |
|
|
0.231.1
by Jelmer Vernooij
Check that regenerated objects have the expected sha1. |
443 |
super(GitBranch, self).__init__(repository.get_mapping()) |
|
0.200.770
by Jelmer Vernooij
Proper branch names. |
444 |
self.ref = ref |
|
0.200.1708
by Jelmer Vernooij
Fix to colocated branch tests. |
445 |
self._head = None |
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
446 |
self._user_transport = controldir.user_transport.clone('.') |
|
0.310.16
by Jelmer Vernooij
Update xfail. |
447 |
self._control_transport = controldir.control_transport.clone('.') |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
448 |
self._tag_refs = None |
|
0.306.1
by Jelmer Vernooij
Set correct segment parameters on branches. |
449 |
params = {} |
|
0.200.1361
by Jelmer Vernooij
Support branches where the ref can't be mapped back to a branch name. |
450 |
try: |
451 |
self.name = ref_to_branch_name(ref) |
|
452 |
except ValueError: |
|
453 |
self.name = None |
|
|
0.200.1708
by Jelmer Vernooij
Fix to colocated branch tests. |
454 |
if self.ref is not None: |
|
0.310.16
by Jelmer Vernooij
Update xfail. |
455 |
params = {"ref": urlutils.escape(self.ref)} |
|
0.200.1708
by Jelmer Vernooij
Fix to colocated branch tests. |
456 |
else: |
457 |
if self.name != "": |
|
|
0.310.16
by Jelmer Vernooij
Update xfail. |
458 |
params = {"branch": urlutils.escape(self.name)} |
459 |
for k, v in params.items(): |
|
460 |
self._user_transport.set_segment_parameter(k, v) |
|
461 |
self._control_transport.set_segment_parameter(k, v) |
|
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
462 |
self.base = controldir.user_transport.base |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
463 |
|
|
0.200.1360
by Jelmer Vernooij
Support lighweight argument to _get_checkout_format. |
464 |
def _get_checkout_format(self, lightweight=False): |
|
0.239.8
by Jelmer Vernooij
Support checkouts. |
465 |
"""Return the most suitable metadir for a checkout of this branch. |
466 |
Weaves are used if this branch's repository uses weaves.
|
|
467 |
"""
|
|
|
0.311.1
by Jelmer Vernooij
Support git lightweight checkouts. |
468 |
if lightweight: |
469 |
return controldir.format_registry.make_controldir("git") |
|
470 |
else: |
|
471 |
return controldir.format_registry.make_controldir("default") |
|
|
0.239.8
by Jelmer Vernooij
Support checkouts. |
472 |
|
|
0.238.3
by Jelmer Vernooij
Remove svn references, prefer git send format when submitting changes against a git branch. |
473 |
def get_child_submit_format(self): |
474 |
"""Return the preferred format of submissions to this branch.""" |
|
|
0.200.1584
by Jelmer Vernooij
Use config stacks in a few more places. |
475 |
ret = self.get_config_stack().get("child_submit_format") |
|
0.238.3
by Jelmer Vernooij
Remove svn references, prefer git send format when submitting changes against a git branch. |
476 |
if ret is not None: |
477 |
return ret |
|
478 |
return "git" |
|
479 |
||
|
0.200.1397
by Jelmer Vernooij
Fix use of get_config() for RemoteGitBranch. |
480 |
def get_config(self): |
|
7490.62.3
by Jelmer Vernooij
Move btree and remove references. |
481 |
from .config import GitBranchConfig |
|
0.200.1397
by Jelmer Vernooij
Fix use of get_config() for RemoteGitBranch. |
482 |
return GitBranchConfig(self) |
483 |
||
|
0.200.1472
by Jelmer Vernooij
Provide basic implementation of Branch.get_config_stack. |
484 |
def get_config_stack(self): |
|
7490.62.3
by Jelmer Vernooij
Move btree and remove references. |
485 |
from .config import GitBranchStack |
|
0.200.1472
by Jelmer Vernooij
Provide basic implementation of Branch.get_config_stack. |
486 |
return GitBranchStack(self) |
487 |
||
|
0.200.293
by Jelmer Vernooij
Fix branch nicks. |
488 |
def _get_nick(self, local=False, possible_master_transports=None): |
489 |
"""Find the nick name for this branch. |
|
490 |
||
491 |
:return: Branch nick
|
|
492 |
"""
|
|
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
493 |
if getattr(self.repository, '_git', None): |
494 |
cs = self.repository._git.get_config_stack() |
|
495 |
try: |
|
|
7143.15.12
by Jelmer Vernooij
Merge trunk. |
496 |
return cs.get((b"branch", self.name.encode('utf-8')), |
|
7143.16.21
by Jelmer Vernooij
Fix regressions. |
497 |
b"nick").decode("utf-8") |
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
498 |
except KeyError: |
499 |
pass
|
|
|
0.200.1694
by Jelmer Vernooij
Fix nick test. |
500 |
return self.name or u"HEAD" |
|
0.200.293
by Jelmer Vernooij
Fix branch nicks. |
501 |
|
|
0.200.331
by Jelmer Vernooij
Add stub for setting nick function. |
502 |
def _set_nick(self, nick): |
|
0.200.1547
by Jelmer Vernooij
Support setting branch nicks. |
503 |
cf = self.repository._git.get_config() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
504 |
cf.set((b"branch", self.name.encode('utf-8')), |
505 |
b"nick", nick.encode("utf-8")) |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
506 |
f = BytesIO() |
|
0.200.1547
by Jelmer Vernooij
Support setting branch nicks. |
507 |
cf.write_to_file(f) |
|
0.288.3
by Jelmer Vernooij
Fix parent URL handling. |
508 |
self.repository._git._put_named_file('config', f.getvalue()) |
|
0.200.331
by Jelmer Vernooij
Add stub for setting nick function. |
509 |
|
510 |
nick = property(_get_nick, _set_nick) |
|
|
0.200.293
by Jelmer Vernooij
Fix branch nicks. |
511 |
|
|
0.200.412
by Jelmer Vernooij
Implement GitBranch.__repr__. |
512 |
def __repr__(self): |
|
0.200.770
by Jelmer Vernooij
Proper branch names. |
513 |
return "<%s(%r, %r)>" % (self.__class__.__name__, self.repository.base, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
514 |
self.name) |
|
0.200.412
by Jelmer Vernooij
Implement GitBranch.__repr__. |
515 |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
516 |
def generate_revision_history(self, revid, last_rev=None, |
517 |
other_branch=None): |
|
|
0.296.2
by Jelmer Vernooij
Handle DivergedBranches. |
518 |
if last_rev is not None: |
519 |
graph = self.repository.get_graph() |
|
520 |
if not graph.is_ancestor(last_rev, revid): |
|
521 |
# our previous tip is not merged into stop_revision
|
|
522 |
raise errors.DivergedBranches(self, other_branch) |
|
523 |
||
|
0.297.2
by Jelmer Vernooij
Simplify Branch.generate_revision_history. |
524 |
self.set_last_revision(revid) |
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
525 |
|
|
0.200.1199
by Jelmer Vernooij
Support 'token' argument to Branch.lock_write. |
526 |
def lock_write(self, token=None): |
527 |
if token is not None: |
|
528 |
raise errors.TokenLockingNotSupported(self) |
|
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
529 |
if self._lock_mode: |
|
0.200.1369
by Jelmer Vernooij
Clarify that ghost tags are not supported. |
530 |
if self._lock_mode == 'r': |
531 |
raise errors.ReadOnlyError(self) |
|
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
532 |
self._lock_count += 1 |
533 |
else: |
|
|
0.383.1
by Jelmer Vernooij
Fix a bunch of locking issues. |
534 |
self._lock_ref() |
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
535 |
self._lock_mode = 'w' |
536 |
self._lock_count = 1 |
|
537 |
self.repository.lock_write() |
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
538 |
return lock.LogicalLockResult(self.unlock) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
539 |
|
|
0.200.1453
by Jelmer Vernooij
Provide Branch.leave_lock_in_place and Branch.dont_leave_lock_in_place. |
540 |
def leave_lock_in_place(self): |
541 |
raise NotImplementedError(self.leave_lock_in_place) |
|
542 |
||
543 |
def dont_leave_lock_in_place(self): |
|
544 |
raise NotImplementedError(self.dont_leave_lock_in_place) |
|
545 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
546 |
def get_stacked_on_url(self): |
547 |
# Git doesn't do stacking (yet...)
|
|
|
0.200.1660
by Jelmer Vernooij
Fix imports. |
548 |
raise branch.UnstackableBranchFormat(self._format, self.base) |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
549 |
|
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
550 |
def _get_push_origin(self, cs): |
|
7141.8.3
by Jelmer Vernooij
Review comments. |
551 |
"""Get the name for the push origin. |
552 |
||
553 |
The exact behaviour is documented in the git-config(1) manpage.
|
|
554 |
"""
|
|
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
555 |
try: |
|
7141.8.3
by Jelmer Vernooij
Review comments. |
556 |
return cs.get((b'branch', self.name.encode('utf-8')), b'pushRemote') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
557 |
except KeyError: |
558 |
try: |
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
559 |
return cs.get((b'branch', ), b'remote') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
560 |
except KeyError: |
561 |
try: |
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
562 |
return cs.get((b'branch', self.name.encode('utf-8')), b'remote') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
563 |
except KeyError: |
564 |
return b'origin' |
|
565 |
||
566 |
def _get_origin(self, cs): |
|
567 |
try: |
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
568 |
return cs.get((b'branch', self.name.encode('utf-8')), b'remote') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
569 |
except KeyError: |
570 |
return b'origin' |
|
571 |
||
572 |
def _get_related_push_branch(self, cs): |
|
573 |
remote = self._get_push_origin(cs) |
|
574 |
try: |
|
575 |
location = cs.get((b"remote", remote), b"url") |
|
576 |
except KeyError: |
|
577 |
return None |
|
578 |
||
579 |
return git_url_to_bzr_url(location.decode('utf-8'), ref=self.ref) |
|
580 |
||
581 |
def _get_related_merge_branch(self, cs): |
|
582 |
remote = self._get_origin(cs) |
|
583 |
try: |
|
584 |
location = cs.get((b"remote", remote), b"url") |
|
585 |
except KeyError: |
|
586 |
return None |
|
587 |
||
588 |
try: |
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
589 |
ref = cs.get((b"branch", remote), b"merge") |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
590 |
except KeyError: |
591 |
ref = self.ref |
|
592 |
||
593 |
return git_url_to_bzr_url(location.decode('utf-8'), ref=ref) |
|
594 |
||
|
0.288.3
by Jelmer Vernooij
Fix parent URL handling. |
595 |
def _get_parent_location(self): |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
596 |
"""See Branch.get_parent().""" |
|
0.288.3
by Jelmer Vernooij
Fix parent URL handling. |
597 |
cs = self.repository._git.get_config_stack() |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
598 |
return self._get_related_merge_branch(cs) |
599 |
||
600 |
def _write_git_config(self, cs): |
|
601 |
f = BytesIO() |
|
602 |
cs.write_to_file(f) |
|
603 |
self.repository._git._put_named_file('config', f.getvalue()) |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
604 |
|
|
0.288.3
by Jelmer Vernooij
Fix parent URL handling. |
605 |
def set_parent(self, location): |
606 |
cs = self.repository._git.get_config() |
|
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
607 |
remote = self._get_origin(cs) |
|
7441.1.1
by Jelmer Vernooij
Add strip_segment_parameters function. |
608 |
this_url = urlutils.strip_segment_parameters(self.user_url) |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
609 |
target_url, branch, ref = bzr_url_to_git_url(location) |
|
0.408.4
by Jelmer Vernooij
Fix some tests. |
610 |
location = urlutils.relative_url(this_url, target_url) |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
611 |
cs.set((b"remote", remote), b"url", location) |
612 |
if branch: |
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
613 |
cs.set((b"branch", remote), b"merge", branch_name_to_ref(branch)) |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
614 |
elif ref: |
|
7141.8.3
by Jelmer Vernooij
Review comments. |
615 |
cs.set((b"branch", remote), b"merge", ref) |
|
0.408.4
by Jelmer Vernooij
Fix some tests. |
616 |
else: |
617 |
# TODO(jelmer): Maybe unset rather than setting to HEAD?
|
|
|
7141.8.3
by Jelmer Vernooij
Review comments. |
618 |
cs.set((b"branch", remote), b"merge", b'HEAD') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
619 |
self._write_git_config(cs) |
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
620 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
621 |
def break_lock(self): |
622 |
raise NotImplementedError(self.break_lock) |
|
623 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
624 |
def lock_read(self): |
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
625 |
if self._lock_mode: |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
626 |
if self._lock_mode not in ('r', 'w'): |
627 |
raise ValueError(self._lock_mode) |
|
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
628 |
self._lock_count += 1 |
629 |
else: |
|
630 |
self._lock_mode = 'r' |
|
631 |
self._lock_count = 1 |
|
632 |
self.repository.lock_read() |
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
633 |
return lock.LogicalLockResult(self.unlock) |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
634 |
|
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
635 |
def peek_lock_mode(self): |
636 |
return self._lock_mode |
|
637 |
||
|
0.200.432
by Jelmer Vernooij
Support Branch.is_locked, required for loggerhead. |
638 |
def is_locked(self): |
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
639 |
return (self._lock_mode is not None) |
|
0.200.432
by Jelmer Vernooij
Support Branch.is_locked, required for loggerhead. |
640 |
|
|
0.383.1
by Jelmer Vernooij
Fix a bunch of locking issues. |
641 |
def _lock_ref(self): |
642 |
pass
|
|
643 |
||
644 |
def _unlock_ref(self): |
|
645 |
pass
|
|
646 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
647 |
def unlock(self): |
|
0.200.1250
by Jelmer Vernooij
Simplify lock handling. |
648 |
"""See Branch.unlock().""" |
649 |
if self._lock_count == 0: |
|
|
0.383.1
by Jelmer Vernooij
Fix a bunch of locking issues. |
650 |
raise errors.LockNotHeld(self) |
651 |
try: |
|
652 |
self._lock_count -= 1 |
|
653 |
if self._lock_count == 0: |
|
654 |
if self._lock_mode == 'w': |
|
655 |
self._unlock_ref() |
|
656 |
self._lock_mode = None |
|
657 |
self._clear_cached_state() |
|
658 |
finally: |
|
659 |
self.repository.unlock() |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
660 |
|
661 |
def get_physical_lock_status(self): |
|
662 |
return False |
|
663 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
664 |
def last_revision(self): |
|
0.200.1675
by Jelmer Vernooij
Remove uses of decorators. |
665 |
with self.lock_read(): |
666 |
# perhaps should escape this ?
|
|
667 |
if self.head is None: |
|
668 |
return revision.NULL_REVISION |
|
669 |
return self.lookup_foreign_revision_id(self.head) |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
670 |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
671 |
def _basic_push(self, target, overwrite=False, stop_revision=None, |
672 |
tag_selector=None): |
|
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
673 |
return branch.InterBranch.get(self, target)._basic_push( |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
674 |
overwrite, stop_revision, tag_selector=tag_selector) |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
675 |
|
|
0.252.49
by Jelmer Vernooij
Avoid trying to set HEAD for remote branches. |
676 |
def lookup_foreign_revision_id(self, foreign_revid): |
|
0.200.1760
by Jelmer Vernooij
Fall back to simple revision id generation. |
677 |
try: |
678 |
return self.repository.lookup_foreign_revision_id(foreign_revid, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
679 |
self.mapping) |
|
0.200.1760
by Jelmer Vernooij
Fall back to simple revision id generation. |
680 |
except KeyError: |
681 |
# Let's try..
|
|
682 |
return self.mapping.revision_id_foreign_to_bzr(foreign_revid) |
|
|
0.252.49
by Jelmer Vernooij
Avoid trying to set HEAD for remote branches. |
683 |
|
|
0.200.1030
by Jelmer Vernooij
More work on supporting roundtripping push. |
684 |
def lookup_bzr_revision_id(self, revid): |
685 |
return self.repository.lookup_bzr_revision_id( |
|
686 |
revid, mapping=self.mapping) |
|
687 |
||
|
0.200.1678
by Jelmer Vernooij
Fix tests. |
688 |
def get_unshelver(self, tree): |
689 |
raise errors.StoringUncommittedNotSupported(self) |
|
690 |
||
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
691 |
def _clear_cached_state(self): |
692 |
super(GitBranch, self)._clear_cached_state() |
|
693 |
self._tag_refs = None |
|
694 |
||
695 |
def _iter_tag_refs(self, refs): |
|
696 |
"""Iterate over the tag refs. |
|
697 |
||
698 |
:param refs: Refs dictionary (name -> git sha1)
|
|
699 |
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
|
|
700 |
"""
|
|
701 |
raise NotImplementedError(self._iter_tag_refs) |
|
702 |
||
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
703 |
def get_tag_refs(self): |
704 |
with self.lock_read(): |
|
705 |
if self._tag_refs is None: |
|
706 |
self._tag_refs = list(self._iter_tag_refs()) |
|
707 |
return self._tag_refs |
|
708 |
||
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
709 |
def import_last_revision_info_and_tags(self, source, revno, revid, |
710 |
lossy=False): |
|
711 |
"""Set the last revision info, importing from another repo if necessary. |
|
712 |
||
713 |
This is used by the bound branch code to upload a revision to
|
|
714 |
the master branch first before updating the tip of the local branch.
|
|
715 |
Revisions referenced by source's tags are also transferred.
|
|
716 |
||
717 |
:param source: Source branch to optionally fetch from
|
|
718 |
:param revno: Revision number of the new tip
|
|
719 |
:param revid: Revision id of the new tip
|
|
720 |
:param lossy: Whether to discard metadata that can not be
|
|
721 |
natively represented
|
|
722 |
:return: Tuple with the new revision number and revision id
|
|
723 |
(should only be different from the arguments when lossy=True)
|
|
724 |
"""
|
|
|
7131.14.2
by Jelmer Vernooij
Make sure resulting branch is correct too. |
725 |
push_result = source.push( |
726 |
self, stop_revision=revid, lossy=lossy, _stop_revno=revno) |
|
727 |
return (push_result.new_revno, push_result.new_revid) |
|
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
728 |
|
|
7206.6.4
by Jelmer Vernooij
Move reconcile logic to breezy.bzr.reconcile. |
729 |
def reconcile(self, thorough=True): |
730 |
"""Make sure the data stored in this branch is consistent.""" |
|
731 |
from ..reconcile import ReconcileResult |
|
732 |
# Nothing to do here
|
|
733 |
return ReconcileResult() |
|
734 |
||
|
0.200.692
by Jelmer Vernooij
Refuse pulling into non-rich-root branches rather than erroring out with an AttributeError. |
735 |
|
|
0.200.465
by Jelmer Vernooij
Use dulwich standard functionality for finding missing revisions. |
736 |
class LocalGitBranch(GitBranch): |
737 |
"""A local Git branch.""" |
|
738 |
||
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
739 |
def __init__(self, controldir, repository, ref): |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
740 |
super(LocalGitBranch, self).__init__(controldir, repository, ref, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
741 |
LocalGitBranchFormat()) |
|
0.200.763
by Jelmer Vernooij
Provide proper colocated branch support. |
742 |
|
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
743 |
def create_checkout(self, to_location, revision_id=None, lightweight=False, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
744 |
accelerator_tree=None, hardlink=False): |
|
0.200.1774
by Jelmer Vernooij
Simplify checkout creation. |
745 |
t = transport.get_transport(to_location) |
746 |
t.ensure_base() |
|
747 |
format = self._get_checkout_format(lightweight=lightweight) |
|
748 |
checkout = format.initialize_on_transport(t) |
|
|
0.200.210
by Jelmer Vernooij
properly error out about not support lightweight checkouts. |
749 |
if lightweight: |
|
0.200.1774
by Jelmer Vernooij
Simplify checkout creation. |
750 |
from_branch = checkout.set_branch_reference(target_branch=self) |
751 |
else: |
|
|
7143.15.14
by Jelmer Vernooij
Fix repo acquisition. |
752 |
policy = checkout.determine_repository_policy() |
753 |
policy.acquire_repository() |
|
|
0.200.1774
by Jelmer Vernooij
Simplify checkout creation. |
754 |
checkout_branch = checkout.create_branch() |
755 |
checkout_branch.bind(self) |
|
756 |
checkout_branch.pull(self, stop_revision=revision_id) |
|
757 |
from_branch = None |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
758 |
return checkout.create_workingtree( |
759 |
revision_id, from_branch=from_branch, hardlink=hardlink) |
|
|
0.200.210
by Jelmer Vernooij
properly error out about not support lightweight checkouts. |
760 |
|
|
0.383.1
by Jelmer Vernooij
Fix a bunch of locking issues. |
761 |
def _lock_ref(self): |
762 |
self._ref_lock = self.repository._git.refs.lock_ref(self.ref) |
|
763 |
||
764 |
def _unlock_ref(self): |
|
765 |
self._ref_lock.unlock() |
|
766 |
||
|
0.412.1
by Jelmer Vernooij
Implement Branch.break_lock. |
767 |
def break_lock(self): |
768 |
self.repository._git.refs.unlock_ref(self.ref) |
|
769 |
||
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
770 |
def _gen_revision_history(self): |
|
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
771 |
if self.head is None: |
772 |
return [] |
|
|
6968.1.1
by Jelmer Vernooij
Support 'bzr version-info' in horizon branches. |
773 |
last_revid = self.last_revision() |
|
0.200.1279
by Jelmer Vernooij
Avoid using deprecated Repository.iter_reverse_revision_history. |
774 |
graph = self.repository.get_graph() |
|
6968.1.1
by Jelmer Vernooij
Support 'bzr version-info' in horizon branches. |
775 |
try: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
776 |
ret = list(graph.iter_lefthand_ancestry( |
777 |
last_revid, (revision.NULL_REVISION, ))) |
|
|
6968.1.1
by Jelmer Vernooij
Support 'bzr version-info' in horizon branches. |
778 |
except errors.RevisionNotPresent as e: |
779 |
raise errors.GhostRevisionsHaveNoRevno(last_revid, e.revision_id) |
|
|
0.200.59
by Jelmer Vernooij
Add more tests, fix revision history. |
780 |
ret.reverse() |
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
781 |
return ret |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
782 |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
783 |
def _get_head(self): |
|
0.200.480
by Jelmer Vernooij
Cope with API changes in Dulwich. |
784 |
try: |
|
0.336.2
by Jelmer Vernooij
Don't use ZERO_SHA outside of remote communication to indicate empty history. |
785 |
return self.repository._git.refs[self.ref] |
|
0.200.480
by Jelmer Vernooij
Cope with API changes in Dulwich. |
786 |
except KeyError: |
787 |
return None |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
788 |
|
|
0.200.1228
by Jelmer Vernooij
Provide Branch._read_last_revision_info. |
789 |
def _read_last_revision_info(self): |
790 |
last_revid = self.last_revision() |
|
791 |
graph = self.repository.get_graph() |
|
|
7143.8.1
by Jelmer Vernooij
Cope with the revno not being known. |
792 |
try: |
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
793 |
revno = graph.find_distance_to_null( |
794 |
last_revid, [(revision.NULL_REVISION, 0)]) |
|
|
7143.8.1
by Jelmer Vernooij
Cope with the revno not being known. |
795 |
except errors.GhostRevisionsHaveNoRevno: |
796 |
revno = None |
|
|
0.200.1228
by Jelmer Vernooij
Provide Branch._read_last_revision_info. |
797 |
return revno, last_revid |
798 |
||
799 |
def set_last_revision_info(self, revno, revision_id): |
|
800 |
self.set_last_revision(revision_id) |
|
801 |
self._last_revision_info_cache = revno, revision_id |
|
|
0.200.507
by Jelmer Vernooij
Implement set_last_revision{_info,}. |
802 |
|
803 |
def set_last_revision(self, revid): |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
804 |
if not revid or not isinstance(revid, bytes): |
|
0.200.1233
by Jelmer Vernooij
Implement Repository.iter_files_bytes. |
805 |
raise errors.InvalidRevisionId(revision_id=revid, branch=self) |
|
0.200.1218
by Jelmer Vernooij
Support set_last_revision('null:'). |
806 |
if revid == NULL_REVISION: |
|
0.336.2
by Jelmer Vernooij
Don't use ZERO_SHA outside of remote communication to indicate empty history. |
807 |
newhead = None |
|
0.200.1218
by Jelmer Vernooij
Support set_last_revision('null:'). |
808 |
else: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
809 |
(newhead, self.mapping) = self.repository.lookup_bzr_revision_id( |
810 |
revid) |
|
|
0.200.1218
by Jelmer Vernooij
Support set_last_revision('null:'). |
811 |
if self.mapping is None: |
812 |
raise AssertionError |
|
813 |
self._set_head(newhead) |
|
|
0.200.507
by Jelmer Vernooij
Implement set_last_revision{_info,}. |
814 |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
815 |
def _set_head(self, value): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
816 |
if value == ZERO_SHA: |
817 |
raise ValueError(value) |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
818 |
self._head = value |
|
0.336.2
by Jelmer Vernooij
Don't use ZERO_SHA outside of remote communication to indicate empty history. |
819 |
if value is None: |
820 |
del self.repository._git.refs[self.ref] |
|
821 |
else: |
|
822 |
self.repository._git.refs[self.ref] = self._head |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
823 |
self._clear_cached_state() |
824 |
||
825 |
head = property(_get_head, _set_head) |
|
826 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
827 |
def get_push_location(self): |
828 |
"""See Branch.get_push_location.""" |
|
|
0.200.1584
by Jelmer Vernooij
Use config stacks in a few more places. |
829 |
push_loc = self.get_config_stack().get('push_location') |
|
7141.8.1
by Jelmer Vernooij
Read parent branch properly from git config. |
830 |
if push_loc is not None: |
831 |
return push_loc |
|
832 |
cs = self.repository._git.get_config_stack() |
|
833 |
return self._get_related_push_branch(cs) |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
834 |
|
835 |
def set_push_location(self, location): |
|
836 |
"""See Branch.set_push_location.""" |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
837 |
self.get_config().set_user_option('push_location', location, |
|
0.217.54
by John Carr
set_user_option breaks - doesnt have a local option in BranchConfig. Follow the bzr.dev syntax instead. |
838 |
store=config.STORE_LOCATION) |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
839 |
|
840 |
def supports_tags(self): |
|
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
841 |
return True |
|
0.200.956
by Jelmer Vernooij
Add some more format tests. |
842 |
|
|
0.200.1681
by Jelmer Vernooij
Provide Branch.store_uncommitted. |
843 |
def store_uncommitted(self, creator): |
844 |
raise errors.StoringUncommittedNotSupported(self) |
|
845 |
||
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
846 |
def _iter_tag_refs(self): |
847 |
"""Iterate over the tag refs. |
|
848 |
||
849 |
:param refs: Refs dictionary (name -> git sha1)
|
|
850 |
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
|
|
851 |
"""
|
|
|
7371.2.1
by Jelmer Vernooij
Fix importing from remote git repositories. |
852 |
refs = self.repository.controldir.get_refs_container() |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
853 |
for ref_name, unpeeled in refs.as_dict().items(): |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
854 |
try: |
855 |
tag_name = ref_to_tag_name(ref_name) |
|
856 |
except (ValueError, UnicodeDecodeError): |
|
857 |
continue
|
|
858 |
peeled = refs.get_peeled(ref_name) |
|
859 |
if peeled is None: |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
860 |
peeled = unpeeled |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
861 |
if not isinstance(tag_name, str): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
862 |
raise TypeError(tag_name) |
|
0.346.1
by Jelmer Vernooij
Fix tag caching. |
863 |
yield (ref_name, tag_name, peeled, unpeeled) |
864 |
||
|
0.360.1
by Jelmer Vernooij
Implement GitMemoryTree. |
865 |
def create_memorytree(self): |
866 |
from .memorytree import GitMemoryTree |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
867 |
return GitMemoryTree(self, self.repository._git.object_store, |
868 |
self.head) |
|
|
0.360.1
by Jelmer Vernooij
Implement GitMemoryTree. |
869 |
|
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
870 |
|
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
871 |
def _quick_lookup_revno(local_branch, remote_branch, revid): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
872 |
if not isinstance(revid, bytes): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
873 |
raise TypeError(revid) |
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
874 |
# Try in source branch first, it'll be faster
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
875 |
with local_branch.lock_read(): |
|
7339.1.6
by Jelmer Vernooij
Also support revno-less push/pull operations. |
876 |
if not _calculate_revnos(local_branch): |
877 |
return None |
|
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
878 |
try: |
|
0.200.1362
by Jelmer Vernooij
Add locking. |
879 |
return local_branch.revision_id_to_revno(revid) |
880 |
except errors.NoSuchRevision: |
|
881 |
graph = local_branch.repository.get_graph() |
|
882 |
try: |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
883 |
return graph.find_distance_to_null( |
884 |
revid, [(revision.NULL_REVISION, 0)]) |
|
|
0.200.1362
by Jelmer Vernooij
Add locking. |
885 |
except errors.GhostRevisionsHaveNoRevno: |
|
7339.1.6
by Jelmer Vernooij
Also support revno-less push/pull operations. |
886 |
if not _calculate_revnos(remote_branch): |
887 |
return None |
|
|
0.200.1362
by Jelmer Vernooij
Add locking. |
888 |
# FIXME: Check using graph.find_distance_to_null() ?
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
889 |
with remote_branch.lock_read(): |
|
0.200.1362
by Jelmer Vernooij
Add locking. |
890 |
return remote_branch.revision_id_to_revno(revid) |
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
891 |
|
892 |
||
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
893 |
class GitBranchPullResult(branch.PullResult): |
894 |
||
|
0.252.36
by Jelmer Vernooij
Fix pull. |
895 |
def __init__(self): |
896 |
super(GitBranchPullResult, self).__init__() |
|
897 |
self.new_git_head = None |
|
898 |
self._old_revno = None |
|
899 |
self._new_revno = None |
|
900 |
||
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
901 |
def report(self, to_file): |
902 |
if not is_quiet(): |
|
903 |
if self.old_revid == self.new_revid: |
|
904 |
to_file.write('No revisions to pull.\n') |
|
|
0.200.728
by Jelmer Vernooij
Fix pulling when all revisions are already in the repo. |
905 |
elif self.new_git_head is not None: |
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
906 |
to_file.write('Now on revision %d (git sha: %s).\n' % |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
907 |
(self.new_revno, self.new_git_head)) |
|
0.200.728
by Jelmer Vernooij
Fix pulling when all revisions are already in the repo. |
908 |
else: |
909 |
to_file.write('Now on revision %d.\n' % (self.new_revno,)) |
|
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
910 |
self._show_tag_conficts(to_file) |
911 |
||
|
0.252.36
by Jelmer Vernooij
Fix pull. |
912 |
def _lookup_revno(self, revid): |
|
0.200.1185
by Jelmer Vernooij
Some formatting fixes. |
913 |
return _quick_lookup_revno(self.target_branch, self.source_branch, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
914 |
revid) |
|
0.252.36
by Jelmer Vernooij
Fix pull. |
915 |
|
916 |
def _get_old_revno(self): |
|
917 |
if self._old_revno is not None: |
|
918 |
return self._old_revno |
|
919 |
return self._lookup_revno(self.old_revid) |
|
920 |
||
921 |
def _set_old_revno(self, revno): |
|
922 |
self._old_revno = revno |
|
923 |
||
924 |
old_revno = property(_get_old_revno, _set_old_revno) |
|
925 |
||
926 |
def _get_new_revno(self): |
|
927 |
if self._new_revno is not None: |
|
928 |
return self._new_revno |
|
929 |
return self._lookup_revno(self.new_revid) |
|
930 |
||
931 |
def _set_new_revno(self, revno): |
|
932 |
self._new_revno = revno |
|
|
0.200.956
by Jelmer Vernooij
Add some more format tests. |
933 |
|
|
0.252.36
by Jelmer Vernooij
Fix pull. |
934 |
new_revno = property(_get_new_revno, _set_new_revno) |
935 |
||
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
936 |
|
|
0.200.504
by Jelmer Vernooij
Lazily find revno's for git branches. |
937 |
class GitBranchPushResult(branch.BranchPushResult): |
938 |
||
939 |
def _lookup_revno(self, revid): |
|
|
0.200.1185
by Jelmer Vernooij
Some formatting fixes. |
940 |
return _quick_lookup_revno(self.source_branch, self.target_branch, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
941 |
revid) |
|
0.200.504
by Jelmer Vernooij
Lazily find revno's for git branches. |
942 |
|
943 |
@property
|
|
944 |
def old_revno(self): |
|
945 |
return self._lookup_revno(self.old_revid) |
|
946 |
||
947 |
@property
|
|
948 |
def new_revno(self): |
|
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
949 |
new_original_revno = getattr(self, "new_original_revno", None) |
950 |
if new_original_revno: |
|
951 |
return new_original_revno |
|
952 |
if getattr(self, "new_original_revid", None) is not None: |
|
953 |
return self._lookup_revno(self.new_original_revid) |
|
|
0.200.504
by Jelmer Vernooij
Lazily find revno's for git branches. |
954 |
return self._lookup_revno(self.new_revid) |
955 |
||
956 |
||
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
957 |
class InterFromGitBranch(branch.GenericInterBranch): |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
958 |
"""InterBranch implementation that pulls from Git into bzr.""" |
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
959 |
|
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
960 |
@staticmethod
|
961 |
def _get_branch_formats_to_test(): |
|
|
0.200.1100
by Jelmer Vernooij
Provide test combinations for InterBranch implementations. |
962 |
try: |
963 |
default_format = branch.format_registry.get_default() |
|
964 |
except AttributeError: |
|
965 |
default_format = branch.BranchFormat._default_format |
|
|
0.295.4
by Jelmer Vernooij
Fix imports. |
966 |
from .remote import RemoteGitBranchFormat |
|
0.200.1100
by Jelmer Vernooij
Provide test combinations for InterBranch implementations. |
967 |
return [ |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
968 |
(RemoteGitBranchFormat(), default_format), |
969 |
(LocalGitBranchFormat(), default_format)] |
|
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
970 |
|
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
971 |
@classmethod
|
|
0.200.692
by Jelmer Vernooij
Refuse pulling into non-rich-root branches rather than erroring out with an AttributeError. |
972 |
def _get_interrepo(self, source, target): |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
973 |
return _mod_repository.InterRepository.get( |
974 |
source.repository, target.repository) |
|
|
0.200.692
by Jelmer Vernooij
Refuse pulling into non-rich-root branches rather than erroring out with an AttributeError. |
975 |
|
976 |
@classmethod
|
|
977 |
def is_compatible(cls, source, target): |
|
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
978 |
if not isinstance(source, GitBranch): |
979 |
return False |
|
980 |
if isinstance(target, GitBranch): |
|
981 |
# InterLocalGitRemoteGitBranch or InterToGitBranch should be used
|
|
982 |
return False |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
983 |
if (getattr(cls._get_interrepo(source, target), "fetch_objects", None) |
984 |
is None): |
|
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
985 |
# fetch_objects is necessary for this to work
|
986 |
return False |
|
987 |
return True |
|
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
988 |
|
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
989 |
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False): |
990 |
self.fetch_objects( |
|
991 |
stop_revision, fetch_tags=fetch_tags, limit=limit, lossy=lossy) |
|
992 |
return _mod_repository.FetchResult() |
|
|
0.260.1
by Jelmer Vernooij
Fix fetch from remote during merge. |
993 |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
994 |
def fetch_objects(self, stop_revision, fetch_tags, limit=None, lossy=False, tag_selector=None): |
|
0.200.692
by Jelmer Vernooij
Refuse pulling into non-rich-root branches rather than erroring out with an AttributeError. |
995 |
interrepo = self._get_interrepo(self.source, self.target) |
|
0.200.1305
by Jelmer Vernooij
Only actually fetch tags if "branch.fetch_tags" is set to true. |
996 |
if fetch_tags is None: |
|
0.200.1584
by Jelmer Vernooij
Use config stacks in a few more places. |
997 |
c = self.source.get_config_stack() |
998 |
fetch_tags = c.get('branch.fetch_tags') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
999 |
|
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
1000 |
def determine_wants(heads): |
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
1001 |
if stop_revision is None: |
|
0.336.6
by Jelmer Vernooij
Fix pull tests. |
1002 |
try: |
|
0.200.917
by Jelmer Vernooij
Cope with implicit branches during pull. |
1003 |
head = heads[self.source.ref] |
|
0.336.6
by Jelmer Vernooij
Fix pull tests. |
1004 |
except KeyError: |
1005 |
self._last_revid = revision.NULL_REVISION |
|
|
0.200.917
by Jelmer Vernooij
Cope with implicit branches during pull. |
1006 |
else: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1007 |
self._last_revid = self.source.lookup_foreign_revision_id( |
1008 |
head) |
|
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
1009 |
else: |
1010 |
self._last_revid = stop_revision |
|
1011 |
real = interrepo.get_determine_wants_revids( |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1012 |
[self._last_revid], include_tags=fetch_tags, tag_selector=tag_selector) |
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
1013 |
return real(heads) |
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
1014 |
pack_hint, head, refs = interrepo.fetch_objects( |
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1015 |
determine_wants, self.source.mapping, limit=limit, |
1016 |
lossy=lossy) |
|
|
0.252.45
by Jelmer Vernooij
Finish fetching roundtripped revisions back into bzr. |
1017 |
if (pack_hint is not None and |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1018 |
self.target.repository._format.pack_compresses): |
|
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
1019 |
self.target.repository.pack(hint=pack_hint) |
|
0.260.1
by Jelmer Vernooij
Fix fetch from remote during merge. |
1020 |
return head, refs |
1021 |
||
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1022 |
def _update_revisions(self, stop_revision=None, overwrite=False, tag_selector=None): |
1023 |
head, refs = self.fetch_objects(stop_revision, fetch_tags=None, tag_selector=tag_selector) |
|
|
0.200.313
by Jelmer Vernooij
Support overwrite parameter. |
1024 |
if overwrite: |
|
0.200.314
by Jelmer Vernooij
Support stop_revision. |
1025 |
prev_last_revid = None |
|
0.200.313
by Jelmer Vernooij
Support overwrite parameter. |
1026 |
else: |
|
0.200.314
by Jelmer Vernooij
Support stop_revision. |
1027 |
prev_last_revid = self.target.last_revision() |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1028 |
self.target.generate_revision_history( |
1029 |
self._last_revid, last_rev=prev_last_revid, |
|
1030 |
other_branch=self.source) |
|
|
0.200.1062
by Jelmer Vernooij
Pass remote refs along in _update_revisions. |
1031 |
return head, refs |
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
1032 |
|
|
7449.1.2
by Jelmer Vernooij
Fix git support. |
1033 |
def update_references(self, revid=None): |
1034 |
if revid is None: |
|
1035 |
revid = self.target.last_revision() |
|
1036 |
tree = self.target.repository.revision_tree(revid) |
|
1037 |
try: |
|
1038 |
with tree.get_file('.gitmodules') as f: |
|
1039 |
for path, url, section in parse_submodules( |
|
1040 |
GitConfigFile.from_file(f)): |
|
1041 |
self.target.set_reference_info( |
|
|
7458.1.1
by Jelmer Vernooij
Support importing Git submodules as tree references. |
1042 |
tree.path2id(path.decode('utf-8')), url.decode('utf-8'), |
1043 |
path.decode('utf-8')) |
|
|
7449.1.2
by Jelmer Vernooij
Fix git support. |
1044 |
except errors.NoSuchFile: |
1045 |
pass
|
|
1046 |
||
|
0.200.1423
by Jelmer Vernooij
Fix space. |
1047 |
def _basic_pull(self, stop_revision, overwrite, run_hooks, |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1048 |
_override_hook_target, _hook_master, tag_selector=None): |
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1049 |
if overwrite is True: |
1050 |
overwrite = set(["history", "tags"]) |
|
|
7142.3.2
by Jelmer Vernooij
Fix overwrite for git branches. |
1051 |
elif not overwrite: |
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1052 |
overwrite = set() |
|
0.200.342
by Jelmer Vernooij
Report git sha during pull. |
1053 |
result = GitBranchPullResult() |
|
0.200.338
by Jelmer Vernooij
Fix dpushing without changes necessary. |
1054 |
result.source_branch = self.source |
1055 |
if _override_hook_target is None: |
|
1056 |
result.target_branch = self.target |
|
1057 |
else: |
|
1058 |
result.target_branch = _override_hook_target |
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
1059 |
with self.target.lock_write(), self.source.lock_read(): |
1060 |
# We assume that during 'pull' the target repository is closer than
|
|
1061 |
# the source one.
|
|
1062 |
(result.old_revno, result.old_revid) = \ |
|
1063 |
self.target.last_revision_info() |
|
1064 |
result.new_git_head, remote_refs = self._update_revisions( |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1065 |
stop_revision, overwrite=("history" in overwrite), |
1066 |
tag_selector=tag_selector) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1067 |
tags_ret = self.source.tags.merge_to( |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1068 |
self.target.tags, ("tags" in overwrite), ignore_master=True) |
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
1069 |
if isinstance(tags_ret, tuple): |
1070 |
result.tag_updates, result.tag_conflicts = tags_ret |
|
1071 |
else: |
|
1072 |
result.tag_conflicts = tags_ret |
|
1073 |
(result.new_revno, result.new_revid) = \ |
|
1074 |
self.target.last_revision_info() |
|
|
7449.1.2
by Jelmer Vernooij
Fix git support. |
1075 |
self.update_references(revid=result.new_revid) |
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
1076 |
if _hook_master: |
1077 |
result.master_branch = _hook_master |
|
1078 |
result.local_branch = result.target_branch |
|
1079 |
else: |
|
1080 |
result.master_branch = result.target_branch |
|
1081 |
result.local_branch = None |
|
1082 |
if run_hooks: |
|
1083 |
for hook in branch.Branch.hooks['post_pull']: |
|
1084 |
hook(result) |
|
1085 |
return result |
|
|
0.200.1414
by Jelmer Vernooij
Fix pulling into bound branches. |
1086 |
|
1087 |
def pull(self, overwrite=False, stop_revision=None, |
|
1088 |
possible_transports=None, _hook_master=None, run_hooks=True, |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1089 |
_override_hook_target=None, local=False, tag_selector=None): |
|
0.200.1414
by Jelmer Vernooij
Fix pulling into bound branches. |
1090 |
"""See Branch.pull. |
1091 |
||
1092 |
:param _hook_master: Private parameter - set the branch to
|
|
1093 |
be supplied as the master to pull hooks.
|
|
1094 |
:param run_hooks: Private parameter - if false, this branch
|
|
1095 |
is being called because it's the master of the primary branch,
|
|
1096 |
so it should not run its hooks.
|
|
1097 |
:param _override_hook_target: Private parameter - set the branch to be
|
|
1098 |
supplied as the target_branch to pull hooks.
|
|
1099 |
"""
|
|
1100 |
# This type of branch can't be bound.
|
|
1101 |
bound_location = self.target.get_bound_location() |
|
1102 |
if local and not bound_location: |
|
1103 |
raise errors.LocalRequiresBoundBranch() |
|
1104 |
source_is_master = False |
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1105 |
with contextlib.ExitStack() as es: |
|
7431.1.1
by Jelmer Vernooij
Ignore ghost tags when interacting with remote Git repositories. |
1106 |
es.enter_context(self.source.lock_read()) |
1107 |
if bound_location: |
|
1108 |
# bound_location comes from a config file, some care has to be
|
|
1109 |
# taken to relate it to source.user_url
|
|
1110 |
normalized = urlutils.normalize_url(bound_location) |
|
1111 |
try: |
|
1112 |
relpath = self.source.user_transport.relpath(normalized) |
|
1113 |
source_is_master = (relpath == '') |
|
1114 |
except (errors.PathNotChild, urlutils.InvalidURL): |
|
1115 |
source_is_master = False |
|
1116 |
if not local and bound_location and not source_is_master: |
|
1117 |
# not pulling from master, so we need to update master.
|
|
1118 |
master_branch = self.target.get_master_branch(possible_transports) |
|
1119 |
es.enter_context(master_branch.lock_write()) |
|
1120 |
# pull from source into master.
|
|
1121 |
master_branch.pull(self.source, overwrite, stop_revision, |
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1122 |
run_hooks=False) |
|
7431.1.1
by Jelmer Vernooij
Ignore ghost tags when interacting with remote Git repositories. |
1123 |
else: |
1124 |
master_branch = None |
|
1125 |
return self._basic_pull(stop_revision, overwrite, run_hooks, |
|
1126 |
_override_hook_target, |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1127 |
_hook_master=master_branch, |
1128 |
tag_selector=tag_selector) |
|
|
0.200.338
by Jelmer Vernooij
Fix dpushing without changes necessary. |
1129 |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1130 |
def _basic_push(self, overwrite, stop_revision, tag_selector=None): |
|
0.331.1
by Jelmer Vernooij
Fix some tags tests. |
1131 |
if overwrite is True: |
1132 |
overwrite = set(["history", "tags"]) |
|
|
7142.3.2
by Jelmer Vernooij
Fix overwrite for git branches. |
1133 |
elif not overwrite: |
|
0.331.1
by Jelmer Vernooij
Fix some tags tests. |
1134 |
overwrite = set() |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1135 |
result = branch.BranchPushResult() |
1136 |
result.source_branch = self.source |
|
1137 |
result.target_branch = self.target |
|
1138 |
result.old_revno, result.old_revid = self.target.last_revision_info() |
|
|
0.200.1219
by Jelmer Vernooij
Remove InterBranch.update_revisions. |
1139 |
result.new_git_head, remote_refs = self._update_revisions( |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1140 |
stop_revision, overwrite=("history" in overwrite), |
1141 |
tag_selector=tag_selector) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1142 |
tags_ret = self.source.tags.merge_to( |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1143 |
self.target.tags, "tags" in overwrite, ignore_master=True, |
1144 |
selector=tag_selector) |
|
|
0.331.1
by Jelmer Vernooij
Fix some tags tests. |
1145 |
(result.tag_updates, result.tag_conflicts) = tags_ret |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1146 |
result.new_revno, result.new_revid = self.target.last_revision_info() |
|
7449.1.2
by Jelmer Vernooij
Fix git support. |
1147 |
self.update_references(revid=result.new_revid) |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1148 |
return result |
1149 |
||
|
0.200.338
by Jelmer Vernooij
Fix dpushing without changes necessary. |
1150 |
|
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1151 |
class InterGitBranch(branch.GenericInterBranch): |
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1152 |
"""InterBranch implementation that pulls between Git branches.""" |
1153 |
||
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1154 |
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False): |
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
1155 |
raise NotImplementedError(self.fetch) |
1156 |
||
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1157 |
|
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
1158 |
class InterLocalGitRemoteGitBranch(InterGitBranch): |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1159 |
"""InterBranch that copies from a local to a remote git branch.""" |
1160 |
||
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
1161 |
@staticmethod
|
1162 |
def _get_branch_formats_to_test(): |
|
|
0.295.4
by Jelmer Vernooij
Fix imports. |
1163 |
from .remote import RemoteGitBranchFormat |
|
0.295.3
by Jelmer Vernooij
Fix some more tests. |
1164 |
return [ |
1165 |
(LocalGitBranchFormat(), RemoteGitBranchFormat())] |
|
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
1166 |
|
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1167 |
@classmethod
|
1168 |
def is_compatible(self, source, target): |
|
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
1169 |
from .remote import RemoteGitBranch |
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
1170 |
return (isinstance(source, LocalGitBranch) and |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1171 |
isinstance(target, RemoteGitBranch)) |
1172 |
||
|
7489.4.7
by Jelmer Vernooij
Fix test. |
1173 |
def _basic_push(self, overwrite, stop_revision, tag_selector=None): |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
1174 |
from .remote import RemoteGitError |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1175 |
result = GitBranchPushResult() |
1176 |
result.source_branch = self.source |
|
1177 |
result.target_branch = self.target |
|
1178 |
if stop_revision is None: |
|
1179 |
stop_revision = self.source.last_revision() |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1180 |
|
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1181 |
def get_changed_refs(old_refs): |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
1182 |
old_ref = old_refs.get(self.target.ref, None) |
1183 |
if old_ref is None: |
|
1184 |
result.old_revid = revision.NULL_REVISION |
|
1185 |
else: |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1186 |
result.old_revid = self.target.lookup_foreign_revision_id( |
1187 |
old_ref) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1188 |
new_ref = self.source.repository.lookup_bzr_revision_id( |
1189 |
stop_revision)[0] |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
1190 |
if not overwrite: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1191 |
if remote_divergence( |
1192 |
old_ref, new_ref, |
|
1193 |
self.source.repository._git.object_store): |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
1194 |
raise errors.DivergedBranches(self.source, self.target) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1195 |
refs = {self.target.ref: new_ref} |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1196 |
result.new_revid = stop_revision |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1197 |
for name, sha in ( |
1198 |
self.source.repository._git.refs.as_dict(b"refs/tags").items()): |
|
|
7489.4.7
by Jelmer Vernooij
Fix test. |
1199 |
if tag_selector and not tag_selector(name): |
1200 |
continue
|
|
|
7431.1.1
by Jelmer Vernooij
Ignore ghost tags when interacting with remote Git repositories. |
1201 |
if sha not in self.source.repository._git: |
1202 |
trace.mutter('Ignoring missing SHA: %s', sha) |
|
1203 |
continue
|
|
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1204 |
refs[tag_name_to_ref(name)] = sha |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1205 |
return refs |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
1206 |
dw_result = self.target.repository.send_pack( |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1207 |
get_changed_refs, |
|
7490.26.2
by Jelmer Vernooij
More shallow work. |
1208 |
self.source.repository._git.generate_pack_data) |
|
7490.60.1
by Jelmer Vernooij
Add support for new push interface in Dulwich >= 0.20.4. |
1209 |
if dw_result is not None and not isinstance(dw_result, dict): |
1210 |
error = dw_result.ref_status.get(self.target.ref) |
|
1211 |
if error: |
|
1212 |
raise RemoteGitError(error) |
|
1213 |
for ref, error in dw_result.ref_status.items(): |
|
1214 |
if error: |
|
1215 |
trace.warning('unable to open ref %s: %s', |
|
1216 |
ref, error) |
|
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1217 |
return result |
1218 |
||
1219 |
||
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
1220 |
class InterGitLocalGitBranch(InterGitBranch): |
|
0.200.512
by Jelmer Vernooij
Support pushing git->git. |
1221 |
"""InterBranch that copies from a remote to a local git branch.""" |
1222 |
||
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
1223 |
@staticmethod
|
1224 |
def _get_branch_formats_to_test(): |
|
|
0.295.4
by Jelmer Vernooij
Fix imports. |
1225 |
from .remote import RemoteGitBranchFormat |
|
0.295.3
by Jelmer Vernooij
Fix some more tests. |
1226 |
return [ |
1227 |
(RemoteGitBranchFormat(), LocalGitBranchFormat()), |
|
1228 |
(LocalGitBranchFormat(), LocalGitBranchFormat())] |
|
|
0.200.996
by Jelmer Vernooij
Fix test run of InterBranches. |
1229 |
|
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1230 |
@classmethod
|
1231 |
def is_compatible(self, source, target): |
|
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
1232 |
return (isinstance(source, GitBranch) and |
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1233 |
isinstance(target, LocalGitBranch)) |
1234 |
||
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1235 |
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False): |
1236 |
interrepo = _mod_repository.InterRepository.get( |
|
1237 |
self.source.repository, self.target.repository) |
|
|
0.200.1534
by Jelmer Vernooij
Implement fetch between git branches, encode nicks. |
1238 |
if stop_revision is None: |
1239 |
stop_revision = self.source.last_revision() |
|
|
7380.1.1
by Jelmer Vernooij
Several more fixes for git merge proposals. |
1240 |
if fetch_tags is None: |
1241 |
c = self.source.get_config_stack() |
|
1242 |
fetch_tags = c.get('branch.fetch_tags') |
|
|
0.200.1534
by Jelmer Vernooij
Implement fetch between git branches, encode nicks. |
1243 |
determine_wants = interrepo.get_determine_wants_revids( |
1244 |
[stop_revision], include_tags=fetch_tags) |
|
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1245 |
interrepo.fetch_objects(determine_wants, limit=limit, lossy=lossy) |
1246 |
return _mod_repository.FetchResult() |
|
|
0.200.1534
by Jelmer Vernooij
Implement fetch between git branches, encode nicks. |
1247 |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1248 |
def _basic_push(self, overwrite=False, stop_revision=None, tag_selector=None): |
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1249 |
if overwrite is True: |
1250 |
overwrite = set(["history", "tags"]) |
|
|
7142.3.2
by Jelmer Vernooij
Fix overwrite for git branches. |
1251 |
elif not overwrite: |
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1252 |
overwrite = set() |
|
0.200.1325
by Jelmer Vernooij
More test fixes. |
1253 |
result = GitBranchPushResult() |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1254 |
result.source_branch = self.source |
1255 |
result.target_branch = self.target |
|
1256 |
result.old_revid = self.target.last_revision() |
|
1257 |
refs, stop_revision = self.update_refs(stop_revision) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1258 |
self.target.generate_revision_history( |
1259 |
stop_revision, |
|
1260 |
(result.old_revid if ("history" not in overwrite) else None), |
|
1261 |
other_branch=self.source) |
|
1262 |
tags_ret = self.source.tags.merge_to( |
|
1263 |
self.target.tags, |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1264 |
overwrite=("tags" in overwrite), |
1265 |
selector=tag_selector) |
|
|
0.200.1402
by Jelmer Vernooij
Cope with tag changes in bzr. |
1266 |
if isinstance(tags_ret, tuple): |
1267 |
(result.tag_updates, result.tag_conflicts) = tags_ret |
|
1268 |
else: |
|
1269 |
result.tag_conflicts = tags_ret |
|
|
0.200.505
by Jelmer Vernooij
Remove duplicate code. |
1270 |
result.new_revid = self.target.last_revision() |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1271 |
return result |
1272 |
||
1273 |
def update_refs(self, stop_revision=None): |
|
|
0.296.1
by Jelmer Vernooij
Fix tag fetching. |
1274 |
interrepo = _mod_repository.InterRepository.get( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1275 |
self.source.repository, self.target.repository) |
|
0.296.1
by Jelmer Vernooij
Fix tag fetching. |
1276 |
c = self.source.get_config_stack() |
1277 |
fetch_tags = c.get('branch.fetch_tags') |
|
1278 |
||
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1279 |
if stop_revision is None: |
|
7455.2.2
by Jelmer Vernooij
Fix git tests. |
1280 |
result = interrepo.fetch(branches=[self.source.ref], include_tags=fetch_tags) |
|
0.336.5
by Jelmer Vernooij
Fix some tests. |
1281 |
try: |
|
7455.2.2
by Jelmer Vernooij
Fix git tests. |
1282 |
head = result.refs[self.source.ref] |
|
0.336.5
by Jelmer Vernooij
Fix some tests. |
1283 |
except KeyError: |
1284 |
stop_revision = revision.NULL_REVISION |
|
1285 |
else: |
|
1286 |
stop_revision = self.target.lookup_foreign_revision_id(head) |
|
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1287 |
else: |
|
7455.2.2
by Jelmer Vernooij
Fix git tests. |
1288 |
result = interrepo.fetch( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1289 |
revision_id=stop_revision, include_tags=fetch_tags) |
|
7455.2.2
by Jelmer Vernooij
Fix git tests. |
1290 |
return result.refs, stop_revision |
|
0.200.501
by Jelmer Vernooij
Support push from git into bzr. |
1291 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
1292 |
def pull(self, stop_revision=None, overwrite=False, |
|
7489.4.6
by Jelmer Vernooij
Fix test. |
1293 |
possible_transports=None, run_hooks=True, local=False, |
1294 |
tag_selector=None): |
|
|
0.200.446
by Jelmer Vernooij
Support new 'local' argument. |
1295 |
# This type of branch can't be bound.
|
1296 |
if local: |
|
1297 |
raise errors.LocalRequiresBoundBranch() |
|
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1298 |
if overwrite is True: |
1299 |
overwrite = set(["history", "tags"]) |
|
|
7142.3.2
by Jelmer Vernooij
Fix overwrite for git branches. |
1300 |
elif not overwrite: |
|
0.343.1
by Jelmer Vernooij
Support overwrite flag properly, remove DictTagDict. |
1301 |
overwrite = set() |
1302 |
||
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1303 |
result = GitPullResult() |
1304 |
result.source_branch = self.source |
|
1305 |
result.target_branch = self.target |
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
1306 |
with self.target.lock_write(), self.source.lock_read(): |
1307 |
result.old_revid = self.target.last_revision() |
|
1308 |
refs, stop_revision = self.update_refs(stop_revision) |
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1309 |
self.target.generate_revision_history( |
1310 |
stop_revision, |
|
1311 |
(result.old_revid if ("history" not in overwrite) else None), |
|
1312 |
other_branch=self.source) |
|
1313 |
tags_ret = self.source.tags.merge_to( |
|
|
7489.4.6
by Jelmer Vernooij
Fix test. |
1314 |
self.target.tags, overwrite=("tags" in overwrite), |
1315 |
selector=tag_selector) |
|
|
0.200.1670
by Jelmer Vernooij
Fix compatibility with newer versions of bzr. |
1316 |
if isinstance(tags_ret, tuple): |
1317 |
(result.tag_updates, result.tag_conflicts) = tags_ret |
|
1318 |
else: |
|
1319 |
result.tag_conflicts = tags_ret |
|
1320 |
result.new_revid = self.target.last_revision() |
|
1321 |
result.local_branch = None |
|
1322 |
result.master_branch = result.target_branch |
|
1323 |
if run_hooks: |
|
1324 |
for hook in branch.Branch.hooks['post_pull']: |
|
1325 |
hook(result) |
|
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1326 |
return result |
1327 |
||
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
1328 |
|
|
0.200.960
by Jelmer Vernooij
Use GenericInterBranch. |
1329 |
class InterToGitBranch(branch.GenericInterBranch): |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1330 |
"""InterBranch implementation that pulls into a Git branch.""" |
|
0.200.468
by Jelmer Vernooij
Move dpush logic onto InterBranch. |
1331 |
|
|
0.200.939
by Jelmer Vernooij
Use InterRepo directly. |
1332 |
def __init__(self, source, target): |
1333 |
super(InterToGitBranch, self).__init__(source, target) |
|
|
0.200.1097
by Jelmer Vernooij
Implement GitBranchFormat.initialize. |
1334 |
self.interrepo = _mod_repository.InterRepository.get(source.repository, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1335 |
target.repository) |
|
0.200.939
by Jelmer Vernooij
Use InterRepo directly. |
1336 |
|
|
0.200.631
by Jelmer Vernooij
Raise proper exception in Branch.get_stacked_on_url(). |
1337 |
@staticmethod
|
1338 |
def _get_branch_formats_to_test(): |
|
|
0.200.1100
by Jelmer Vernooij
Provide test combinations for InterBranch implementations. |
1339 |
try: |
1340 |
default_format = branch.format_registry.get_default() |
|
1341 |
except AttributeError: |
|
1342 |
default_format = branch.BranchFormat._default_format |
|
|
0.295.4
by Jelmer Vernooij
Fix imports. |
1343 |
from .remote import RemoteGitBranchFormat |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
1344 |
return [ |
1345 |
(default_format, LocalGitBranchFormat()), |
|
1346 |
(default_format, RemoteGitBranchFormat())] |
|
|
0.200.631
by Jelmer Vernooij
Raise proper exception in Branch.get_stacked_on_url(). |
1347 |
|
|
0.200.468
by Jelmer Vernooij
Move dpush logic onto InterBranch. |
1348 |
@classmethod
|
1349 |
def is_compatible(self, source, target): |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
1350 |
return (not isinstance(source, GitBranch) and |
|
0.200.468
by Jelmer Vernooij
Move dpush logic onto InterBranch. |
1351 |
isinstance(target, GitBranch)) |
1352 |
||
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
1353 |
def _get_new_refs(self, stop_revision=None, fetch_tags=None, |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1354 |
stop_revno=None): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
1355 |
if not self.source.is_locked(): |
1356 |
raise errors.ObjectNotLocked(self.source) |
|
|
0.252.38
by Jelmer Vernooij
Minor cleanups. |
1357 |
if stop_revision is None: |
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
1358 |
(stop_revno, stop_revision) = self.source.last_revision_info() |
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
1359 |
elif stop_revno is None: |
|
7296.4.1
by Jelmer Vernooij
Fix pushing non-mainline revisions from bzr to git. |
1360 |
try: |
1361 |
stop_revno = self.source.revision_id_to_revno(stop_revision) |
|
1362 |
except errors.NoSuchRevision: |
|
1363 |
stop_revno = None |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1364 |
if not isinstance(stop_revision, bytes): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
1365 |
raise TypeError(stop_revision) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
1366 |
main_ref = self.target.ref |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1367 |
refs = {main_ref: (None, stop_revision)} |
|
0.200.1363
by Jelmer Vernooij
Only fetch tags if requested in config. |
1368 |
if fetch_tags is None: |
|
0.200.1584
by Jelmer Vernooij
Use config stacks in a few more places. |
1369 |
c = self.source.get_config_stack() |
1370 |
fetch_tags = c.get('branch.fetch_tags') |
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1371 |
for name, revid in self.source.tags.get_tag_dict().items(): |
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1372 |
if self.source.repository.has_revision(revid): |
1373 |
ref = tag_name_to_ref(name) |
|
1374 |
if not check_ref_format(ref): |
|
1375 |
warning("skipping tag with invalid characters %s (%s)", |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1376 |
name, ref) |
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1377 |
continue
|
|
0.200.1398
by Jelmer Vernooij
Make GitSmartRemoteNotSupported derive from UnsupportedOperation. |
1378 |
if fetch_tags: |
1379 |
# FIXME: Skip tags that are not in the ancestry
|
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1380 |
refs[ref] = (None, revid) |
|
0.200.1048
by Jelmer Vernooij
Make lookup of revno's after push/pull as efficient as possible. |
1381 |
return refs, main_ref, (stop_revno, stop_revision) |
|
0.252.37
by Jelmer Vernooij
Factor out some common code for finding refs to send. |
1382 |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1383 |
def _update_refs(self, result, old_refs, new_refs, overwrite, tag_selector): |
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1384 |
mutter("updating refs. old refs: %r, new refs: %r", |
1385 |
old_refs, new_refs) |
|
1386 |
result.tag_updates = {} |
|
1387 |
result.tag_conflicts = [] |
|
1388 |
ret = dict(old_refs) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1389 |
|
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1390 |
def ref_equals(refs, ref, git_sha, revid): |
1391 |
try: |
|
1392 |
value = refs[ref] |
|
1393 |
except KeyError: |
|
1394 |
return False |
|
1395 |
if (value[0] is not None and |
|
1396 |
git_sha is not None and |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1397 |
value[0] == git_sha): |
|
0.200.1479
by Jelmer Vernooij
Simplify branch ref handling. |
1398 |
return True |
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1399 |
if (value[1] is not None and |
1400 |
revid is not None and |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1401 |
value[1] == revid): |
|
0.200.1479
by Jelmer Vernooij
Simplify branch ref handling. |
1402 |
return True |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1403 |
# FIXME: If one side only has the git sha available and the other
|
1404 |
# only has the bzr revid, then this will cause us to show a tag as
|
|
1405 |
# updated that hasn't actually been updated.
|
|
|
0.200.1479
by Jelmer Vernooij
Simplify branch ref handling. |
1406 |
return False |
|
0.200.1474
by Jelmer Vernooij
Cope with refs when pushing. |
1407 |
# FIXME: Check for diverged branches
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1408 |
for ref, (git_sha, revid) in new_refs.items(): |
|
0.200.1479
by Jelmer Vernooij
Simplify branch ref handling. |
1409 |
if ref_equals(ret, ref, git_sha, revid): |
1410 |
# Already up to date
|
|
1411 |
if git_sha is None: |
|
1412 |
git_sha = old_refs[ref][0] |
|
1413 |
if revid is None: |
|
1414 |
revid = old_refs[ref][1] |
|
1415 |
ret[ref] = new_refs[ref] = (git_sha, revid) |
|
1416 |
elif ref not in ret or overwrite: |
|
1417 |
try: |
|
1418 |
tag_name = ref_to_tag_name(ref) |
|
1419 |
except ValueError: |
|
1420 |
pass
|
|
1421 |
else: |
|
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1422 |
if tag_selector and not tag_selector(tag_name): |
1423 |
continue
|
|
|
0.200.1479
by Jelmer Vernooij
Simplify branch ref handling. |
1424 |
result.tag_updates[tag_name] = revid |
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1425 |
ret[ref] = (git_sha, revid) |
1426 |
else: |
|
|
0.200.1474
by Jelmer Vernooij
Cope with refs when pushing. |
1427 |
# FIXME: Check diverged
|
1428 |
diverged = False |
|
1429 |
if diverged: |
|
1430 |
try: |
|
1431 |
name = ref_to_tag_name(ref) |
|
1432 |
except ValueError: |
|
1433 |
pass
|
|
1434 |
else: |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1435 |
result.tag_conflicts.append( |
1436 |
(name, revid, ret[name][1])) |
|
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1437 |
else: |
|
0.200.1474
by Jelmer Vernooij
Cope with refs when pushing. |
1438 |
ret[ref] = (git_sha, revid) |
|
0.200.1392
by Jelmer Vernooij
Preserve existing refs. |
1439 |
return ret |
1440 |
||
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1441 |
def fetch(self, stop_revision=None, fetch_tags=None, lossy=False, |
1442 |
limit=None): |
|
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
1443 |
if stop_revision is None: |
|
7455.2.3
by Jelmer Vernooij
Fix remaining tests. |
1444 |
stop_revision = self.source.last_revision() |
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
1445 |
ret = [] |
1446 |
if fetch_tags: |
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1447 |
for k, v in self.source.tags.get_tag_dict().items(): |
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
1448 |
ret.append((None, v)) |
1449 |
ret.append((None, stop_revision)) |
|
|
0.320.5
by Jelmer Vernooij
Always raise NoRoundtrippingSupport rather than NoPushSupport. |
1450 |
try: |
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1451 |
revidmap = self.interrepo.fetch_objects(ret, lossy=lossy, limit=limit) |
|
0.320.5
by Jelmer Vernooij
Always raise NoRoundtrippingSupport rather than NoPushSupport. |
1452 |
except NoPushSupport: |
1453 |
raise errors.NoRoundtrippingSupport(self.source, self.target) |
|
|
7455.2.1
by Jelmer Vernooij
Return a FetchResult object from Repository.fetch / Branch.fetch. |
1454 |
return _mod_repository.FetchResult(revidmap={ |
1455 |
old_revid: new_revid |
|
1456 |
for (old_revid, (new_sha, new_revid)) in revidmap.items()}) |
|
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
1457 |
|
|
0.252.36
by Jelmer Vernooij
Fix pull. |
1458 |
def pull(self, overwrite=False, stop_revision=None, local=False, |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1459 |
possible_transports=None, run_hooks=True, _stop_revno=None, |
1460 |
tag_selector=None): |
|
|
0.252.36
by Jelmer Vernooij
Fix pull. |
1461 |
result = GitBranchPullResult() |
1462 |
result.source_branch = self.source |
|
1463 |
result.target_branch = self.target |
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
1464 |
with self.source.lock_read(), self.target.lock_write(): |
1465 |
new_refs, main_ref, stop_revinfo = self._get_new_refs( |
|
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
1466 |
stop_revision, stop_revno=_stop_revno) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1467 |
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
1468 |
def update_refs(old_refs): |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1469 |
return self._update_refs(result, old_refs, new_refs, overwrite, tag_selector) |
|
0.200.1353
by Jelmer Vernooij
Run various hooks. |
1470 |
try: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1471 |
result.revidmap, old_refs, new_refs = ( |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1472 |
self.interrepo.fetch_refs(update_refs, lossy=False)) |
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
1473 |
except NoPushSupport: |
1474 |
raise errors.NoRoundtrippingSupport(self.source, self.target) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1475 |
(old_sha1, result.old_revid) = old_refs.get( |
1476 |
main_ref, (ZERO_SHA, NULL_REVISION)) |
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
1477 |
if result.old_revid is None: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1478 |
result.old_revid = self.target.lookup_foreign_revision_id( |
1479 |
old_sha1) |
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
1480 |
result.new_revid = new_refs[main_ref][1] |
1481 |
result.local_branch = None |
|
1482 |
result.master_branch = self.target |
|
1483 |
if run_hooks: |
|
1484 |
for hook in branch.Branch.hooks['post_pull']: |
|
1485 |
hook(result) |
|
|
0.252.36
by Jelmer Vernooij
Fix pull. |
1486 |
return result |
1487 |
||
|
0.200.1260
by Jelmer Vernooij
Cope with new lossy argument. |
1488 |
def push(self, overwrite=False, stop_revision=None, lossy=False, |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1489 |
_override_hook_source_branch=None, _stop_revno=None, |
1490 |
tag_selector=None): |
|
|
0.252.5
by Jelmer Vernooij
enable 'bzr push'. |
1491 |
result = GitBranchPushResult() |
1492 |
result.source_branch = self.source |
|
1493 |
result.target_branch = self.target |
|
|
0.200.1356
by Jelmer Vernooij
Fix result properties for hook. |
1494 |
result.local_branch = None |
1495 |
result.master_branch = result.target_branch |
|
|
0.331.1
by Jelmer Vernooij
Fix some tags tests. |
1496 |
with self.source.lock_read(), self.target.lock_write(): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1497 |
new_refs, main_ref, stop_revinfo = self._get_new_refs( |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
1498 |
stop_revision, stop_revno=_stop_revno) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1499 |
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1500 |
def update_refs(old_refs): |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
1501 |
return self._update_refs(result, old_refs, new_refs, overwrite, tag_selector) |
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1502 |
try: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1503 |
result.revidmap, old_refs, new_refs = ( |
1504 |
self.interrepo.fetch_refs( |
|
1505 |
update_refs, lossy=lossy, overwrite=overwrite)) |
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1506 |
except NoPushSupport: |
1507 |
raise errors.NoRoundtrippingSupport(self.source, self.target) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1508 |
(old_sha1, result.old_revid) = old_refs.get( |
1509 |
main_ref, (ZERO_SHA, NULL_REVISION)) |
|
|
7446.1.2
by Jelmer Vernooij
Fix working tree update of incremental lossy push. |
1510 |
if lossy or result.old_revid is None: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1511 |
result.old_revid = self.target.lookup_foreign_revision_id( |
1512 |
old_sha1) |
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1513 |
result.new_revid = new_refs[main_ref][1] |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
1514 |
(result.new_original_revno, |
1515 |
result.new_original_revid) = stop_revinfo |
|
|
0.200.1391
by Jelmer Vernooij
Warn on (and skip) invalid tags. |
1516 |
for hook in branch.Branch.hooks['post_push']: |
1517 |
hook(result) |
|
|
0.252.5
by Jelmer Vernooij
enable 'bzr push'. |
1518 |
return result |
|
0.200.472
by Jelmer Vernooij
Fix printing error when user attempts to push into git. |
1519 |
|
|
0.200.334
by Jelmer Vernooij
Support pulling from git to git. |
1520 |
|
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
1521 |
branch.InterBranch.register_optimiser(InterGitLocalGitBranch) |
|
0.200.468
by Jelmer Vernooij
Move dpush logic onto InterBranch. |
1522 |
branch.InterBranch.register_optimiser(InterFromGitBranch) |
1523 |
branch.InterBranch.register_optimiser(InterToGitBranch) |
|
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
1524 |
branch.InterBranch.register_optimiser(InterLocalGitRemoteGitBranch) |