76
112
return self._lookup_revno(self.new_revid)
79
class LocalGitTagDict(tag.BasicTags):
80
"""Dictionary with tags in a local repository."""
115
class GitTags(tag.BasicTags):
116
"""Ref-based tag dictionary."""
82
118
def __init__(self, branch):
83
119
self.branch = branch
84
120
self.repository = branch.repository
122
def _merge_to_remote_git(self, target_repo, source_tag_refs,
127
def get_changed_refs(old_refs):
129
for ref_name, tag_name, peeled, unpeeled in (
130
source_tag_refs.iteritems()):
131
if old_refs.get(ref_name) == unpeeled:
133
elif overwrite or ref_name not in old_refs:
134
ret[ref_name] = unpeeled
135
updates[tag_name] = target_repo.lookup_foreign_revision_id(
140
self.repository.lookup_foreign_revision_id(peeled),
141
target_repo.lookup_foreign_revision_id(
142
old_refs[ref_name])))
144
target_repo.controldir.send_pack(
145
get_changed_refs, lambda have, want: [])
146
return updates, conflicts
148
def _merge_to_local_git(self, target_repo, source_tag_refs,
152
for ref_name, tag_name, peeled, unpeeled in source_tag_refs:
153
if target_repo._git.refs.get(ref_name) == unpeeled:
155
elif overwrite or ref_name not in target_repo._git.refs:
157
updates[tag_name] = (
158
target_repo.lookup_foreign_revision_id(peeled))
160
trace.warning('%s does not point to a valid object',
163
except NotCommitError:
164
trace.warning('%s points to a non-commit object',
167
target_repo._git.refs[ref_name] = unpeeled or peeled
170
source_revid = self.repository.lookup_foreign_revision_id(
172
target_revid = target_repo.lookup_foreign_revision_id(
173
target_repo._git.refs[ref_name])
175
trace.warning('%s does not point to a valid object',
178
except NotCommitError:
179
trace.warning('%s points to a non-commit object',
182
conflicts.append((tag_name, source_revid, target_revid))
183
return updates, conflicts
185
def _merge_to_git(self, to_tags, source_tag_refs, overwrite=False):
186
target_repo = to_tags.repository
187
if self.repository.has_same_location(target_repo):
190
if getattr(target_repo, "_git", None):
191
return self._merge_to_local_git(
192
target_repo, source_tag_refs, overwrite)
194
return self._merge_to_remote_git(
195
target_repo, source_tag_refs, overwrite)
197
to_tags.branch._tag_refs = None
199
def _merge_to_non_git(self, to_tags, source_tag_refs, overwrite=False):
200
unpeeled_map = defaultdict(set)
203
result = dict(to_tags.get_tag_dict())
204
for ref_name, tag_name, peeled, unpeeled in source_tag_refs:
205
if unpeeled is not None:
206
unpeeled_map[peeled].add(unpeeled)
208
bzr_revid = self.branch.lookup_foreign_revision_id(peeled)
209
except NotCommitError:
211
if result.get(tag_name) == bzr_revid:
213
elif tag_name not in result or overwrite:
214
result[tag_name] = bzr_revid
215
updates[tag_name] = bzr_revid
217
conflicts.append((tag_name, bzr_revid, result[tag_name]))
218
to_tags._set_tag_dict(result)
219
if len(unpeeled_map) > 0:
220
map_file = UnpeelMap.from_repository(to_tags.branch.repository)
221
map_file.update(unpeeled_map)
222
map_file.save_in_repository(to_tags.branch.repository)
223
return updates, conflicts
225
def merge_to(self, to_tags, overwrite=False, ignore_master=False,
226
source_tag_refs=None):
227
"""See Tags.merge_to."""
228
if source_tag_refs is None:
229
source_tag_refs = self.branch.get_tag_refs()
232
if isinstance(to_tags, GitTags):
233
return self._merge_to_git(to_tags, source_tag_refs,
239
master = to_tags.branch.get_master_branch()
240
with contextlib.ExitStack() as es:
241
if master is not None:
242
es.enter_context(master.lock_write())
243
updates, conflicts = self._merge_to_non_git(
244
to_tags, source_tag_refs, overwrite=overwrite)
245
if master is not None:
246
extra_updates, extra_conflicts = self.merge_to(
247
master.tags, overwrite=overwrite,
248
source_tag_refs=source_tag_refs,
249
ignore_master=ignore_master)
250
updates.update(extra_updates)
251
conflicts += extra_conflicts
252
return updates, conflicts
86
254
def get_tag_dict(self):
88
for k,v in extract_tags(self.repository._git.get_refs()).iteritems():
256
for (ref_name, tag_name, peeled, unpeeled) in (
257
self.branch.get_tag_refs()):
90
obj = self.repository._git[v]
92
mutter("Tag %s points at unknown object %s, ignoring", v, obj)
94
while isinstance(obj, Tag):
96
obj = self.repository._git[v]
97
if not isinstance(obj, Commit):
98
mutter("Tag %s points at object %r that is not a commit, "
101
ret[k] = self.branch.lookup_foreign_revision_id(v)
259
bzr_revid = self.branch.lookup_foreign_revision_id(peeled)
260
except NotCommitError:
263
ret[tag_name] = bzr_revid
267
class LocalGitTagDict(GitTags):
268
"""Dictionary with tags in a local repository."""
270
def __init__(self, branch):
271
super(LocalGitTagDict, self).__init__(branch)
272
self.refs = self.repository.controldir._git.refs
104
274
def _set_tag_dict(self, to_dict):
105
extra = set(self.repository._git.get_refs().keys())
106
for k, revid in to_dict.iteritems():
275
extra = set(self.refs.allkeys())
276
for k, revid in to_dict.items():
107
277
name = tag_name_to_ref(k)
108
278
if name in extra:
109
279
extra.remove(name)
110
self.set_tag(k, revid)
281
self.set_tag(k, revid)
282
except errors.GhostTagsNotSupported:
111
284
for name in extra:
112
if name.startswith("refs/tags/"):
113
286
del self.repository._git[name]
115
288
def set_tag(self, name, revid):
116
self.repository._git.refs[tag_name_to_ref(name)], _ = \
117
self.branch.lookup_bzr_revision_id(revid)
120
class DictTagDict(LocalGitTagDict):
122
def __init__(self, branch, tags):
123
super(DictTagDict, self).__init__(branch)
126
def get_tag_dict(self):
290
git_sha, mapping = self.branch.lookup_bzr_revision_id(revid)
291
except errors.NoSuchRevision:
292
raise errors.GhostTagsNotSupported(self)
293
self.refs[tag_name_to_ref(name)] = git_sha
294
self.branch._tag_refs = None
296
def delete_tag(self, name):
297
ref = tag_name_to_ref(name)
298
if ref not in self.refs:
299
raise errors.NoSuchTag(name)
301
self.branch._tag_refs = None
130
304
class GitBranchFormat(branch.BranchFormat):
132
def get_format_description(self):
135
306
def network_name(self):
138
309
def supports_tags(self):
312
def supports_leaving_lock(self):
315
def supports_tags_referencing_ghosts(self):
318
def tags_are_versioned(self):
141
321
def get_foreign_tests_branch_factory(self):
142
from bzrlib.plugins.git.tests.test_branch import ForeignTestsBranchFactory
322
from .tests.test_branch import ForeignTestsBranchFactory
143
323
return ForeignTestsBranchFactory()
145
325
def make_tags(self, branch):
146
if getattr(branch.repository, "get_refs", None) is not None:
147
from bzrlib.plugins.git.remote import RemoteGitTagDict
328
except AttributeError:
330
if getattr(branch.repository, "_git", None) is None:
331
from .remote import RemoteGitTagDict
148
332
return RemoteGitTagDict(branch)
150
334
return LocalGitTagDict(branch)
153
class GitReadLock(object):
155
def __init__(self, unlock):
159
class GitWriteLock(object):
161
def __init__(self, unlock):
336
def initialize(self, a_controldir, name=None, repository=None,
337
append_revisions_only=None):
338
raise NotImplementedError(self.initialize)
340
def get_reference(self, controldir, name=None):
341
return controldir.get_branch_reference(name=name)
343
def set_reference(self, controldir, name, target):
344
return controldir.set_branch_reference(target, name)
346
def stores_revno(self):
347
"""True if this branch format store revision numbers."""
350
supports_reference_locations = False
353
class LocalGitBranchFormat(GitBranchFormat):
355
def get_format_description(self):
356
return 'Local Git Branch'
359
def _matchingcontroldir(self):
360
from .dir import LocalGitControlDirFormat
361
return LocalGitControlDirFormat()
363
def initialize(self, a_controldir, name=None, repository=None,
364
append_revisions_only=None):
365
from .dir import LocalGitDir
366
if not isinstance(a_controldir, LocalGitDir):
367
raise errors.IncompatibleFormat(self, a_controldir._format)
368
return a_controldir.create_branch(
369
repository=repository, name=name,
370
append_revisions_only=append_revisions_only)
165
373
class GitBranch(ForeignBranch):
166
374
"""An adapter to git repositories for bzr Branch objects."""
168
def __init__(self, bzrdir, repository, ref, lockfiles, tagsdict=None):
377
def control_transport(self):
378
return self._control_transport
381
def user_transport(self):
382
return self._user_transport
384
def __init__(self, controldir, repository, ref, format):
169
385
self.repository = repository
170
self._format = GitBranchFormat()
171
self.control_files = lockfiles
386
self._format = format
387
self.controldir = controldir
388
self._lock_mode = None
173
390
super(GitBranch, self).__init__(repository.get_mapping())
174
if tagsdict is not None:
175
self.tags = DictTagDict(self, tagsdict)
177
self.name = ref_to_branch_name(ref)
178
392
self._head = None
179
self.base = bzrdir.root_transport.base
393
self._user_transport = controldir.user_transport.clone('.')
394
self._control_transport = controldir.control_transport.clone('.')
395
self._tag_refs = None
398
self.name = ref_to_branch_name(ref)
401
if self.ref is not None:
402
params = {"ref": urlutils.escape(self.ref)}
405
params = {"branch": urlutils.escape(self.name)}
406
for k, v in params.items():
407
self._user_transport.set_segment_parameter(k, v)
408
self._control_transport.set_segment_parameter(k, v)
409
self.base = controldir.user_transport.base
181
def _get_checkout_format(self):
411
def _get_checkout_format(self, lightweight=False):
182
412
"""Return the most suitable metadir for a checkout of this branch.
183
413
Weaves are used if this branch's repository uses weaves.
185
return bzrdir.format_registry.make_bzrdir("default")
416
return controldir.format_registry.make_controldir("git")
418
return controldir.format_registry.make_controldir("default")
187
420
def get_child_submit_format(self):
188
421
"""Return the preferred format of submissions to this branch."""
189
ret = self.get_config().get_user_option("child_submit_format")
422
ret = self.get_config_stack().get("child_submit_format")
190
423
if ret is not None:
427
def get_config(self):
428
return GitBranchConfig(self)
430
def get_config_stack(self):
431
return GitBranchStack(self)
194
433
def _get_nick(self, local=False, possible_master_transports=None):
195
434
"""Find the nick name for this branch.
197
436
:return: Branch nick
199
return self.name or "HEAD"
438
if getattr(self.repository, '_git', None):
439
cs = self.repository._git.get_config_stack()
441
return cs.get((b"branch", self.name.encode('utf-8')),
442
b"nick").decode("utf-8")
445
return self.name or u"HEAD"
201
447
def _set_nick(self, nick):
202
raise NotImplementedError
448
cf = self.repository._git.get_config()
449
cf.set((b"branch", self.name.encode('utf-8')),
450
b"nick", nick.encode("utf-8"))
453
self.repository._git._put_named_file('config', f.getvalue())
204
455
nick = property(_get_nick, _set_nick)
206
457
def __repr__(self):
207
458
return "<%s(%r, %r)>" % (self.__class__.__name__, self.repository.base,
210
def generate_revision_history(self, revid, old_revid=None):
211
# FIXME: Check that old_revid is in the ancestry of revid
212
newhead, self.mapping = self.mapping.revision_id_bzr_to_foreign(revid)
213
self._set_head(newhead)
215
def lock_write(self):
216
self.control_files.lock_write()
217
return GitWriteLock(self.unlock)
461
def generate_revision_history(self, revid, last_rev=None,
463
if last_rev is not None:
464
graph = self.repository.get_graph()
465
if not graph.is_ancestor(last_rev, revid):
466
# our previous tip is not merged into stop_revision
467
raise errors.DivergedBranches(self, other_branch)
469
self.set_last_revision(revid)
471
def lock_write(self, token=None):
472
if token is not None:
473
raise errors.TokenLockingNotSupported(self)
475
if self._lock_mode == 'r':
476
raise errors.ReadOnlyError(self)
477
self._lock_count += 1
480
self._lock_mode = 'w'
482
self.repository.lock_write()
483
return lock.LogicalLockResult(self.unlock)
485
def leave_lock_in_place(self):
486
raise NotImplementedError(self.leave_lock_in_place)
488
def dont_leave_lock_in_place(self):
489
raise NotImplementedError(self.dont_leave_lock_in_place)
219
491
def get_stacked_on_url(self):
220
492
# Git doesn't do stacking (yet...)
221
raise errors.UnstackableBranchFormat(self._format, self.base)
223
def get_parent(self):
493
raise branch.UnstackableBranchFormat(self._format, self.base)
495
def _get_push_origin(self, cs):
496
"""Get the name for the push origin.
498
The exact behaviour is documented in the git-config(1) manpage.
501
return cs.get((b'branch', self.name.encode('utf-8')), b'pushRemote')
504
return cs.get((b'branch', ), b'remote')
507
return cs.get((b'branch', self.name.encode('utf-8')), b'remote')
511
def _get_origin(self, cs):
513
return cs.get((b'branch', self.name.encode('utf-8')), b'remote')
517
def _get_related_push_branch(self, cs):
518
remote = self._get_push_origin(cs)
520
location = cs.get((b"remote", remote), b"url")
524
return git_url_to_bzr_url(location.decode('utf-8'), ref=self.ref)
526
def _get_related_merge_branch(self, cs):
527
remote = self._get_origin(cs)
529
location = cs.get((b"remote", remote), b"url")
534
ref = cs.get((b"branch", remote), b"merge")
538
return git_url_to_bzr_url(location.decode('utf-8'), ref=ref)
540
def _get_parent_location(self):
224
541
"""See Branch.get_parent()."""
225
# FIXME: Set "origin" url from .git/config ?
228
def set_parent(self, url):
229
# FIXME: Set "origin" url in .git/config ?
542
cs = self.repository._git.get_config_stack()
543
return self._get_related_merge_branch(cs)
545
def _write_git_config(self, cs):
548
self.repository._git._put_named_file('config', f.getvalue())
550
def set_parent(self, location):
551
cs = self.repository._git.get_config()
552
remote = self._get_origin(cs)
553
this_url = urlutils.strip_segment_parameters(self.user_url)
554
target_url, branch, ref = bzr_url_to_git_url(location)
555
location = urlutils.relative_url(this_url, target_url)
556
cs.set((b"remote", remote), b"url", location)
558
cs.set((b"branch", remote), b"merge", branch_name_to_ref(branch))
560
cs.set((b"branch", remote), b"merge", ref)
562
# TODO(jelmer): Maybe unset rather than setting to HEAD?
563
cs.set((b"branch", remote), b"merge", b'HEAD')
564
self._write_git_config(cs)
566
def break_lock(self):
567
raise NotImplementedError(self.break_lock)
232
569
def lock_read(self):
233
self.control_files.lock_read()
234
return GitReadLock(self.unlock)
571
if self._lock_mode not in ('r', 'w'):
572
raise ValueError(self._lock_mode)
573
self._lock_count += 1
575
self._lock_mode = 'r'
577
self.repository.lock_read()
578
return lock.LogicalLockResult(self.unlock)
580
def peek_lock_mode(self):
581
return self._lock_mode
236
583
def is_locked(self):
237
return self.control_files.is_locked()
584
return (self._lock_mode is not None)
589
def _unlock_ref(self):
239
592
def unlock(self):
240
self.control_files.unlock()
593
"""See Branch.unlock()."""
594
if self._lock_count == 0:
595
raise errors.LockNotHeld(self)
597
self._lock_count -= 1
598
if self._lock_count == 0:
599
if self._lock_mode == 'w':
601
self._lock_mode = None
602
self._clear_cached_state()
604
self.repository.unlock()
242
606
def get_physical_lock_status(self):
246
609
def last_revision(self):
247
# perhaps should escape this ?
248
if self.head is None:
249
return revision.NULL_REVISION
250
return self.lookup_foreign_revision_id(self.head)
610
with self.lock_read():
611
# perhaps should escape this ?
612
if self.head is None:
613
return revision.NULL_REVISION
614
return self.lookup_foreign_revision_id(self.head)
252
616
def _basic_push(self, target, overwrite=False, stop_revision=None):
253
617
return branch.InterBranch.get(self, target)._basic_push(
254
618
overwrite, stop_revision)
256
620
def lookup_foreign_revision_id(self, foreign_revid):
257
return self.repository.lookup_foreign_revision_id(foreign_revid,
622
return self.repository.lookup_foreign_revision_id(foreign_revid,
626
return self.mapping.revision_id_foreign_to_bzr(foreign_revid)
260
628
def lookup_bzr_revision_id(self, revid):
261
629
return self.repository.lookup_bzr_revision_id(
262
630
revid, mapping=self.mapping)
632
def get_unshelver(self, tree):
633
raise errors.StoringUncommittedNotSupported(self)
635
def _clear_cached_state(self):
636
super(GitBranch, self)._clear_cached_state()
637
self._tag_refs = None
639
def _iter_tag_refs(self, refs):
640
"""Iterate over the tag refs.
642
:param refs: Refs dictionary (name -> git sha1)
643
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
645
raise NotImplementedError(self._iter_tag_refs)
647
def get_tag_refs(self):
648
with self.lock_read():
649
if self._tag_refs is None:
650
self._tag_refs = list(self._iter_tag_refs())
651
return self._tag_refs
653
def import_last_revision_info_and_tags(self, source, revno, revid,
655
"""Set the last revision info, importing from another repo if necessary.
657
This is used by the bound branch code to upload a revision to
658
the master branch first before updating the tip of the local branch.
659
Revisions referenced by source's tags are also transferred.
661
:param source: Source branch to optionally fetch from
662
:param revno: Revision number of the new tip
663
:param revid: Revision id of the new tip
664
:param lossy: Whether to discard metadata that can not be
666
:return: Tuple with the new revision number and revision id
667
(should only be different from the arguments when lossy=True)
669
push_result = source.push(
670
self, stop_revision=revid, lossy=lossy, _stop_revno=revno)
671
return (push_result.new_revno, push_result.new_revid)
673
def reconcile(self, thorough=True):
674
"""Make sure the data stored in this branch is consistent."""
675
from ..reconcile import ReconcileResult
677
return ReconcileResult()
265
680
class LocalGitBranch(GitBranch):
266
681
"""A local Git branch."""
268
def __init__(self, bzrdir, repository, name, lockfiles, tagsdict=None):
269
super(LocalGitBranch, self).__init__(bzrdir, repository, name,
271
refs = repository._git.get_refs()
272
if not (name in refs.keys() or "HEAD" in refs.keys()):
273
raise errors.NotBranchError(self.base)
683
def __init__(self, controldir, repository, ref):
684
super(LocalGitBranch, self).__init__(controldir, repository, ref,
685
LocalGitBranchFormat())
275
687
def create_checkout(self, to_location, revision_id=None, lightweight=False,
276
accelerator_tree=None, hardlink=False):
688
accelerator_tree=None, hardlink=False):
689
t = transport.get_transport(to_location)
691
format = self._get_checkout_format(lightweight=lightweight)
692
checkout = format.initialize_on_transport(t)
278
t = transport.get_transport(to_location)
280
format = self._get_checkout_format()
281
checkout = format.initialize_on_transport(t)
282
from_branch = branch.BranchReferenceFormat().initialize(checkout,
284
tree = checkout.create_workingtree(revision_id,
285
from_branch=from_branch, hardlink=hardlink)
694
from_branch = checkout.set_branch_reference(target_branch=self)
288
return self._create_heavyweight_checkout(to_location, revision_id,
291
def _create_heavyweight_checkout(self, to_location, revision_id=None,
293
"""Create a new heavyweight checkout of this branch.
295
:param to_location: URL of location to create the new checkout in.
296
:param revision_id: Revision that should be the tip of the checkout.
297
:param hardlink: Whether to hardlink
298
:return: WorkingTree object of checkout.
300
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
301
to_location, force_new_tree=False)
302
checkout = checkout_branch.bzrdir
303
checkout_branch.bind(self)
304
# pull up to the specified revision_id to set the initial
305
# branch tip correctly, and seed it with history.
306
checkout_branch.pull(self, stop_revision=revision_id)
307
return checkout.create_workingtree(revision_id, hardlink=hardlink)
696
policy = checkout.determine_repository_policy()
697
policy.acquire_repository()
698
checkout_branch = checkout.create_branch()
699
checkout_branch.bind(self)
700
checkout_branch.pull(self, stop_revision=revision_id)
702
return checkout.create_workingtree(
703
revision_id, from_branch=from_branch, hardlink=hardlink)
706
self._ref_lock = self.repository._git.refs.lock_ref(self.ref)
708
def _unlock_ref(self):
709
self._ref_lock.unlock()
711
def break_lock(self):
712
self.repository._git.refs.unlock_ref(self.ref)
309
714
def _gen_revision_history(self):
310
715
if self.head is None:
312
ret = list(self.repository.iter_reverse_revision_history(
313
self.last_revision()))
717
last_revid = self.last_revision()
718
graph = self.repository.get_graph()
720
ret = list(graph.iter_lefthand_ancestry(
721
last_revid, (revision.NULL_REVISION, )))
722
except errors.RevisionNotPresent as e:
723
raise errors.GhostRevisionsHaveNoRevno(last_revid, e.revision_id)
317
727
def _get_head(self):
319
return self.repository._git.ref(self.ref or "HEAD")
729
return self.repository._git.refs[self.ref]
323
def set_last_revision_info(self, revno, revid):
324
self.set_last_revision(revid)
733
def _read_last_revision_info(self):
734
last_revid = self.last_revision()
735
graph = self.repository.get_graph()
737
revno = graph.find_distance_to_null(
738
last_revid, [(revision.NULL_REVISION, 0)])
739
except errors.GhostRevisionsHaveNoRevno:
741
return revno, last_revid
743
def set_last_revision_info(self, revno, revision_id):
744
self.set_last_revision(revision_id)
745
self._last_revision_info_cache = revno, revision_id
326
747
def set_last_revision(self, revid):
327
(newhead, self.mapping) = self.repository.lookup_bzr_revision_id(revid)
748
if not revid or not isinstance(revid, bytes):
749
raise errors.InvalidRevisionId(revision_id=revid, branch=self)
750
if revid == NULL_REVISION:
753
(newhead, self.mapping) = self.repository.lookup_bzr_revision_id(
755
if self.mapping is None:
757
self._set_head(newhead)
330
759
def _set_head(self, value):
760
if value == ZERO_SHA:
761
raise ValueError(value)
331
762
self._head = value
332
self.repository._git.refs[self.ref or "HEAD"] = self._head
764
del self.repository._git.refs[self.ref]
766
self.repository._git.refs[self.ref] = self._head
333
767
self._clear_cached_state()
335
769
head = property(_get_head, _set_head)
337
def get_config(self):
338
return GitBranchConfig(self)
340
771
def get_push_location(self):
341
772
"""See Branch.get_push_location."""
342
push_loc = self.get_config().get_user_option('push_location')
773
push_loc = self.get_config_stack().get('push_location')
774
if push_loc is not None:
776
cs = self.repository._git.get_config_stack()
777
return self._get_related_push_branch(cs)
345
779
def set_push_location(self, location):
346
780
"""See Branch.set_push_location."""
427
905
def _get_branch_formats_to_test():
907
default_format = branch.format_registry.get_default()
908
except AttributeError:
909
default_format = branch.BranchFormat._default_format
910
from .remote import RemoteGitBranchFormat
912
(RemoteGitBranchFormat(), default_format),
913
(LocalGitBranchFormat(), default_format)]
431
916
def _get_interrepo(self, source, target):
432
return repository.InterRepository.get(source.repository,
917
return _mod_repository.InterRepository.get(
918
source.repository, target.repository)
436
921
def is_compatible(cls, source, target):
437
return (isinstance(source, GitBranch) and
438
not isinstance(target, GitBranch) and
439
(getattr(cls._get_interrepo(source, target), "fetch_objects", None) is not None))
441
def _update_revisions(self, stop_revision=None, overwrite=False,
442
graph=None, limit=None):
443
"""Like InterBranch.update_revisions(), but with additions.
445
Compared to the `update_revisions()` below, this function takes a
446
`limit` argument that limits how many git commits will be converted
447
and returns the new git head.
922
if not isinstance(source, GitBranch):
924
if isinstance(target, GitBranch):
925
# InterLocalGitRemoteGitBranch or InterToGitBranch should be used
927
if (getattr(cls._get_interrepo(source, target), "fetch_objects", None)
929
# fetch_objects is necessary for this to work
933
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False):
935
stop_revision, fetch_tags=fetch_tags, limit=limit, lossy=lossy)
936
return _mod_repository.FetchResult()
938
def fetch_objects(self, stop_revision, fetch_tags, limit=None, lossy=False):
449
939
interrepo = self._get_interrepo(self.source, self.target)
940
if fetch_tags is None:
941
c = self.source.get_config_stack()
942
fetch_tags = c.get('branch.fetch_tags')
450
944
def determine_wants(heads):
451
if self.source.ref is not None and not self.source.ref in heads:
452
raise NoSuchRef(self.source.ref, heads.keys())
453
if stop_revision is not None:
945
if stop_revision is None:
947
head = heads[self.source.ref]
949
self._last_revid = revision.NULL_REVISION
951
self._last_revid = self.source.lookup_foreign_revision_id(
454
954
self._last_revid = stop_revision
455
head, mapping = self.source.repository.lookup_bzr_revision_id(
458
if self.source.ref is not None:
459
head = heads[self.source.ref]
462
self._last_revid = self.source.lookup_foreign_revision_id(head)
463
if self.target.repository.has_revision(self._last_revid):
955
real = interrepo.get_determine_wants_revids(
956
[self._last_revid], include_tags=fetch_tags)
466
958
pack_hint, head, refs = interrepo.fetch_objects(
467
determine_wants, self.source.mapping, limit=limit)
959
determine_wants, self.source.mapping, limit=limit,
468
961
if (pack_hint is not None and
469
self.target.repository._format.pack_compresses):
962
self.target.repository._format.pack_compresses):
470
963
self.target.repository.pack(hint=pack_hint)
472
self._last_revid = self.source.lookup_foreign_revision_id(head)
966
def _update_revisions(self, stop_revision=None, overwrite=False):
967
head, refs = self.fetch_objects(stop_revision, fetch_tags=None)
474
969
prev_last_revid = None
476
971
prev_last_revid = self.target.last_revision()
477
self.target.generate_revision_history(self._last_revid,
481
def update_revisions(self, stop_revision=None, overwrite=False,
483
"""See InterBranch.update_revisions()."""
484
self._update_revisions(stop_revision, overwrite, graph)
486
def pull(self, overwrite=False, stop_revision=None,
487
possible_transports=None, _hook_master=None, run_hooks=True,
488
_override_hook_target=None, local=False, limit=None):
491
:param _hook_master: Private parameter - set the branch to
492
be supplied as the master to pull hooks.
493
:param run_hooks: Private parameter - if false, this branch
494
is being called because it's the master of the primary branch,
495
so it should not run its hooks.
496
:param _override_hook_target: Private parameter - set the branch to be
497
supplied as the target_branch to pull hooks.
498
:param limit: Only import this many revisons. `None`, the default,
499
means import all revisions.
501
# This type of branch can't be bound.
503
raise errors.LocalRequiresBoundBranch()
972
self.target.generate_revision_history(
973
self._last_revid, last_rev=prev_last_revid,
974
other_branch=self.source)
977
def update_references(self, revid=None):
979
revid = self.target.last_revision()
980
tree = self.target.repository.revision_tree(revid)
982
with tree.get_file('.gitmodules') as f:
983
for path, url, section in parse_submodules(
984
GitConfigFile.from_file(f)):
985
self.target.set_reference_info(
986
tree.path2id(path.decode('utf-8')), url.decode('utf-8'),
987
path.decode('utf-8'))
988
except errors.NoSuchFile:
991
def _basic_pull(self, stop_revision, overwrite, run_hooks,
992
_override_hook_target, _hook_master):
993
if overwrite is True:
994
overwrite = set(["history", "tags"])
504
997
result = GitBranchPullResult()
505
998
result.source_branch = self.source
506
999
if _override_hook_target is None:
507
1000
result.target_branch = self.target
509
1002
result.target_branch = _override_hook_target
510
self.source.lock_read()
1003
with self.target.lock_write(), self.source.lock_read():
512
1004
# We assume that during 'pull' the target repository is closer than
513
1005
# the source one.
514
graph = self.target.repository.get_graph(self.source.repository)
515
1006
(result.old_revno, result.old_revid) = \
516
1007
self.target.last_revision_info()
517
result.new_git_head = self._update_revisions(
518
stop_revision, overwrite=overwrite, graph=graph, limit=limit)
519
result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
1008
result.new_git_head, remote_refs = self._update_revisions(
1009
stop_revision, overwrite=("history" in overwrite))
1010
tags_ret = self.source.tags.merge_to(
1011
self.target.tags, ("tags" in overwrite), ignore_master=True)
1012
if isinstance(tags_ret, tuple):
1013
result.tag_updates, result.tag_conflicts = tags_ret
1015
result.tag_conflicts = tags_ret
521
1016
(result.new_revno, result.new_revid) = \
522
1017
self.target.last_revision_info()
1018
self.update_references(revid=result.new_revid)
523
1019
if _hook_master:
524
1020
result.master_branch = _hook_master
525
1021
result.local_branch = result.target_branch
530
1026
for hook in branch.Branch.hooks['post_pull']:
536
def _basic_push(self, overwrite=False, stop_revision=None):
1030
def pull(self, overwrite=False, stop_revision=None,
1031
possible_transports=None, _hook_master=None, run_hooks=True,
1032
_override_hook_target=None, local=False):
1035
:param _hook_master: Private parameter - set the branch to
1036
be supplied as the master to pull hooks.
1037
:param run_hooks: Private parameter - if false, this branch
1038
is being called because it's the master of the primary branch,
1039
so it should not run its hooks.
1040
:param _override_hook_target: Private parameter - set the branch to be
1041
supplied as the target_branch to pull hooks.
1043
# This type of branch can't be bound.
1044
bound_location = self.target.get_bound_location()
1045
if local and not bound_location:
1046
raise errors.LocalRequiresBoundBranch()
1047
source_is_master = False
1048
with contextlib.ExitStack() as es:
1049
es.enter_context(self.source.lock_read())
1051
# bound_location comes from a config file, some care has to be
1052
# taken to relate it to source.user_url
1053
normalized = urlutils.normalize_url(bound_location)
1055
relpath = self.source.user_transport.relpath(normalized)
1056
source_is_master = (relpath == '')
1057
except (errors.PathNotChild, urlutils.InvalidURL):
1058
source_is_master = False
1059
if not local and bound_location and not source_is_master:
1060
# not pulling from master, so we need to update master.
1061
master_branch = self.target.get_master_branch(possible_transports)
1062
es.enter_context(master_branch.lock_write())
1063
# pull from source into master.
1064
master_branch.pull(self.source, overwrite, stop_revision,
1067
master_branch = None
1068
return self._basic_pull(stop_revision, overwrite, run_hooks,
1069
_override_hook_target,
1070
_hook_master=master_branch)
1072
def _basic_push(self, overwrite, stop_revision):
1073
if overwrite is True:
1074
overwrite = set(["history", "tags"])
537
1077
result = branch.BranchPushResult()
538
1078
result.source_branch = self.source
539
1079
result.target_branch = self.target
540
graph = self.target.repository.get_graph(self.source.repository)
541
1080
result.old_revno, result.old_revid = self.target.last_revision_info()
542
result.new_git_head = self._update_revisions(
543
stop_revision, overwrite=overwrite, graph=graph)
544
result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
1081
result.new_git_head, remote_refs = self._update_revisions(
1082
stop_revision, overwrite=("history" in overwrite))
1083
tags_ret = self.source.tags.merge_to(
1084
self.target.tags, "tags" in overwrite, ignore_master=True)
1085
(result.tag_updates, result.tag_conflicts) = tags_ret
546
1086
result.new_revno, result.new_revid = self.target.last_revision_info()
1087
self.update_references(revid=result.new_revid)
550
1091
class InterGitBranch(branch.GenericInterBranch):
551
1092
"""InterBranch implementation that pulls between Git branches."""
554
class InterGitLocalRemoteBranch(InterGitBranch):
1094
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False):
1095
raise NotImplementedError(self.fetch)
1098
class InterLocalGitRemoteGitBranch(InterGitBranch):
555
1099
"""InterBranch that copies from a local to a remote git branch."""
558
1102
def _get_branch_formats_to_test():
1103
from .remote import RemoteGitBranchFormat
1105
(LocalGitBranchFormat(), RemoteGitBranchFormat())]
562
1108
def is_compatible(self, source, target):
563
from bzrlib.plugins.git.remote import RemoteGitBranch
1109
from .remote import RemoteGitBranch
564
1110
return (isinstance(source, LocalGitBranch) and
565
1111
isinstance(target, RemoteGitBranch))
567
def _basic_push(self, overwrite=False, stop_revision=None):
568
from dulwich.protocol import ZERO_SHA
1113
def _basic_push(self, overwrite, stop_revision):
569
1114
result = GitBranchPushResult()
570
1115
result.source_branch = self.source
571
1116
result.target_branch = self.target
572
1117
if stop_revision is None:
573
1118
stop_revision = self.source.last_revision()
574
# FIXME: Check for diverged branches
575
1120
def get_changed_refs(old_refs):
576
result.old_revid = self.target.lookup_foreign_revision_id(old_refs.get(self.target.ref, ZERO_SHA))
577
refs = { self.target.ref: self.source.repository.lookup_bzr_revision_id(stop_revision)[0] }
1121
old_ref = old_refs.get(self.target.ref, None)
1123
result.old_revid = revision.NULL_REVISION
1125
result.old_revid = self.target.lookup_foreign_revision_id(
1127
new_ref = self.source.repository.lookup_bzr_revision_id(
1130
if remote_divergence(
1132
self.source.repository._git.object_store):
1133
raise errors.DivergedBranches(self.source, self.target)
1134
refs = {self.target.ref: new_ref}
578
1135
result.new_revid = stop_revision
579
for name, sha in self.source.repository._git.refs.as_dict("refs/tags").iteritems():
1137
self.source.repository._git.refs.as_dict(b"refs/tags").items()):
1138
if sha not in self.source.repository._git:
1139
trace.mutter('Ignoring missing SHA: %s', sha)
580
1141
refs[tag_name_to_ref(name)] = sha
582
self.target.repository.send_pack(get_changed_refs,
583
self.source.repository._git.object_store.generate_pack_contents)
1143
self.target.repository.send_pack(
1145
self.source.repository._git.object_store.generate_pack_data)
587
class InterGitRemoteLocalBranch(InterGitBranch):
1149
class InterGitLocalGitBranch(InterGitBranch):
588
1150
"""InterBranch that copies from a remote to a local git branch."""
591
1153
def _get_branch_formats_to_test():
1154
from .remote import RemoteGitBranchFormat
1156
(RemoteGitBranchFormat(), LocalGitBranchFormat()),
1157
(LocalGitBranchFormat(), LocalGitBranchFormat())]
595
1160
def is_compatible(self, source, target):
596
from bzrlib.plugins.git.remote import RemoteGitBranch
597
return (isinstance(source, RemoteGitBranch) and
1161
return (isinstance(source, GitBranch) and
598
1162
isinstance(target, LocalGitBranch))
1164
def fetch(self, stop_revision=None, fetch_tags=None, limit=None, lossy=False):
1165
interrepo = _mod_repository.InterRepository.get(
1166
self.source.repository, self.target.repository)
1167
if stop_revision is None:
1168
stop_revision = self.source.last_revision()
1169
if fetch_tags is None:
1170
c = self.source.get_config_stack()
1171
fetch_tags = c.get('branch.fetch_tags')
1172
determine_wants = interrepo.get_determine_wants_revids(
1173
[stop_revision], include_tags=fetch_tags)
1174
interrepo.fetch_objects(determine_wants, limit=limit, lossy=lossy)
1175
return _mod_repository.FetchResult()
600
1177
def _basic_push(self, overwrite=False, stop_revision=None):
601
result = branch.BranchPushResult()
1178
if overwrite is True:
1179
overwrite = set(["history", "tags"])
1182
result = GitBranchPushResult()
602
1183
result.source_branch = self.source
603
1184
result.target_branch = self.target
604
1185
result.old_revid = self.target.last_revision()
605
1186
refs, stop_revision = self.update_refs(stop_revision)
606
self.target.generate_revision_history(stop_revision, result.old_revid)
607
self.update_tags(refs)
1187
self.target.generate_revision_history(
1189
(result.old_revid if ("history" not in overwrite) else None),
1190
other_branch=self.source)
1191
tags_ret = self.source.tags.merge_to(
1193
source_tag_refs=remote_refs_dict_to_tag_refs(refs),
1194
overwrite=("tags" in overwrite))
1195
if isinstance(tags_ret, tuple):
1196
(result.tag_updates, result.tag_conflicts) = tags_ret
1198
result.tag_conflicts = tags_ret
608
1199
result.new_revid = self.target.last_revision()
611
def update_tags(self, refs):
612
for name, v in extract_tags(refs).iteritems():
613
revid = self.target.lookup_foreign_revision_id(v)
614
self.target.tags.set_tag(name, revid)
616
1202
def update_refs(self, stop_revision=None):
617
interrepo = repository.InterRepository.get(self.source.repository,
618
self.target.repository)
1203
interrepo = _mod_repository.InterRepository.get(
1204
self.source.repository, self.target.repository)
1205
c = self.source.get_config_stack()
1206
fetch_tags = c.get('branch.fetch_tags')
619
1208
if stop_revision is None:
620
refs = interrepo.fetch(branches=["HEAD"])
621
stop_revision = self.target.lookup_foreign_revision_id(refs["HEAD"])
1209
result = interrepo.fetch(branches=[self.source.ref], include_tags=fetch_tags)
1211
head = result.refs[self.source.ref]
1213
stop_revision = revision.NULL_REVISION
1215
stop_revision = self.target.lookup_foreign_revision_id(head)
623
refs = interrepo.fetch(revision_id=stop_revision)
624
return refs, stop_revision
1217
result = interrepo.fetch(
1218
revision_id=stop_revision, include_tags=fetch_tags)
1219
return result.refs, stop_revision
626
1221
def pull(self, stop_revision=None, overwrite=False,
627
possible_transports=None, run_hooks=True,local=False):
1222
possible_transports=None, run_hooks=True, local=False):
628
1223
# This type of branch can't be bound.
630
1225
raise errors.LocalRequiresBoundBranch()
1226
if overwrite is True:
1227
overwrite = set(["history", "tags"])
631
1231
result = GitPullResult()
632
1232
result.source_branch = self.source
633
1233
result.target_branch = self.target
634
result.old_revid = self.target.last_revision()
635
refs, stop_revision = self.update_refs(stop_revision)
636
self.target.generate_revision_history(stop_revision, result.old_revid)
637
self.update_tags(refs)
638
result.new_revid = self.target.last_revision()
1234
with self.target.lock_write(), self.source.lock_read():
1235
result.old_revid = self.target.last_revision()
1236
refs, stop_revision = self.update_refs(stop_revision)
1237
self.target.generate_revision_history(
1239
(result.old_revid if ("history" not in overwrite) else None),
1240
other_branch=self.source)
1241
tags_ret = self.source.tags.merge_to(
1242
self.target.tags, overwrite=("tags" in overwrite),
1243
source_tag_refs=remote_refs_dict_to_tag_refs(refs))
1244
if isinstance(tags_ret, tuple):
1245
(result.tag_updates, result.tag_conflicts) = tags_ret
1247
result.tag_conflicts = tags_ret
1248
result.new_revid = self.target.last_revision()
1249
result.local_branch = None
1250
result.master_branch = result.target_branch
1252
for hook in branch.Branch.hooks['post_pull']:
642
1257
class InterToGitBranch(branch.GenericInterBranch):
643
"""InterBranch implementation that pulls from Git into bzr."""
1258
"""InterBranch implementation that pulls into a Git branch."""
645
1260
def __init__(self, source, target):
646
1261
super(InterToGitBranch, self).__init__(source, target)
647
self.interrepo = repository.InterRepository.get(source.repository,
1262
self.interrepo = _mod_repository.InterRepository.get(source.repository,
651
1266
def _get_branch_formats_to_test():
1268
default_format = branch.format_registry.get_default()
1269
except AttributeError:
1270
default_format = branch.BranchFormat._default_format
1271
from .remote import RemoteGitBranchFormat
1273
(default_format, LocalGitBranchFormat()),
1274
(default_format, RemoteGitBranchFormat())]
655
1277
def is_compatible(self, source, target):
656
1278
return (not isinstance(source, GitBranch) and
657
1279
isinstance(target, GitBranch))
659
def update_revisions(self, *args, **kwargs):
660
raise NoPushSupport()
662
def _get_new_refs(self, stop_revision=None):
1281
def _get_new_refs(self, stop_revision=None, fetch_tags=None,
1283
if not self.source.is_locked():
1284
raise errors.ObjectNotLocked(self.source)
663
1285
if stop_revision is None:
664
stop_revision = self.source.last_revision()
665
assert type(stop_revision) is str
666
main_ref = self.target.ref or "refs/heads/master"
667
refs = { main_ref: (None, stop_revision) }
668
for name, revid in self.source.tags.get_tag_dict().iteritems():
1286
(stop_revno, stop_revision) = self.source.last_revision_info()
1287
elif stop_revno is None:
1289
stop_revno = self.source.revision_id_to_revno(stop_revision)
1290
except errors.NoSuchRevision:
1292
if not isinstance(stop_revision, bytes):
1293
raise TypeError(stop_revision)
1294
main_ref = self.target.ref
1295
refs = {main_ref: (None, stop_revision)}
1296
if fetch_tags is None:
1297
c = self.source.get_config_stack()
1298
fetch_tags = c.get('branch.fetch_tags')
1299
for name, revid in self.source.tags.get_tag_dict().items():
669
1300
if self.source.repository.has_revision(revid):
670
refs[tag_name_to_ref(name)] = (None, revid)
671
return refs, main_ref
1301
ref = tag_name_to_ref(name)
1302
if not check_ref_format(ref):
1303
warning("skipping tag with invalid characters %s (%s)",
1307
# FIXME: Skip tags that are not in the ancestry
1308
refs[ref] = (None, revid)
1309
return refs, main_ref, (stop_revno, stop_revision)
1311
def _update_refs(self, result, old_refs, new_refs, overwrite):
1312
mutter("updating refs. old refs: %r, new refs: %r",
1314
result.tag_updates = {}
1315
result.tag_conflicts = []
1316
ret = dict(old_refs)
1318
def ref_equals(refs, ref, git_sha, revid):
1323
if (value[0] is not None and
1324
git_sha is not None and
1325
value[0] == git_sha):
1327
if (value[1] is not None and
1328
revid is not None and
1331
# FIXME: If one side only has the git sha available and the other
1332
# only has the bzr revid, then this will cause us to show a tag as
1333
# updated that hasn't actually been updated.
1335
# FIXME: Check for diverged branches
1336
for ref, (git_sha, revid) in new_refs.items():
1337
if ref_equals(ret, ref, git_sha, revid):
1338
# Already up to date
1340
git_sha = old_refs[ref][0]
1342
revid = old_refs[ref][1]
1343
ret[ref] = new_refs[ref] = (git_sha, revid)
1344
elif ref not in ret or overwrite:
1346
tag_name = ref_to_tag_name(ref)
1350
result.tag_updates[tag_name] = revid
1351
ret[ref] = (git_sha, revid)
1353
# FIXME: Check diverged
1357
name = ref_to_tag_name(ref)
1361
result.tag_conflicts.append(
1362
(name, revid, ret[name][1]))
1364
ret[ref] = (git_sha, revid)
1367
def fetch(self, stop_revision=None, fetch_tags=None, lossy=False,
1369
if stop_revision is None:
1370
stop_revision = self.source.last_revision()
1373
for k, v in self.source.tags.get_tag_dict().items():
1374
ret.append((None, v))
1375
ret.append((None, stop_revision))
1377
revidmap = self.interrepo.fetch_objects(ret, lossy=lossy, limit=limit)
1378
except NoPushSupport:
1379
raise errors.NoRoundtrippingSupport(self.source, self.target)
1380
return _mod_repository.FetchResult(revidmap={
1381
old_revid: new_revid
1382
for (old_revid, (new_sha, new_revid)) in revidmap.items()})
673
1384
def pull(self, overwrite=False, stop_revision=None, local=False,
674
possible_transports=None):
675
from dulwich.protocol import ZERO_SHA
1385
possible_transports=None, run_hooks=True, _stop_revno=None):
676
1386
result = GitBranchPullResult()
677
1387
result.source_branch = self.source
678
1388
result.target_branch = self.target
679
new_refs, main_ref = self._get_new_refs(stop_revision)
680
def update_refs(old_refs):
681
refs = dict(old_refs)
682
# FIXME: Check for diverged branches
683
refs.update(new_refs)
685
old_refs, new_refs = self.interrepo.fetch_refs(update_refs)
686
result.old_revid = self.target.lookup_foreign_revision_id(
687
old_refs.get(main_ref, ZERO_SHA))
688
result.new_revid = new_refs[main_ref]
691
def push(self, overwrite=False, stop_revision=None,
692
_override_hook_source_branch=None):
693
from dulwich.protocol import ZERO_SHA
694
result = GitBranchPushResult()
695
result.source_branch = self.source
696
result.target_branch = self.target
697
new_refs, main_ref = self._get_new_refs(stop_revision)
698
def update_refs(old_refs):
699
refs = dict(old_refs)
700
# FIXME: Check for diverged branches
701
refs.update(new_refs)
703
old_refs, new_refs = self.interrepo.fetch_refs(update_refs)
704
(result.old_revid, old_sha1) = old_refs.get(main_ref, (ZERO_SHA, NULL_REVISION))
705
if result.old_revid is None:
706
result.old_revid = self.target.lookup_foreign_revision_id(old_sha1)
707
result.new_revid = new_refs[main_ref]
710
def lossy_push(self, stop_revision=None):
711
result = GitBranchPushResult()
712
result.source_branch = self.source
713
result.target_branch = self.target
714
new_refs, main_ref = self._get_new_refs(stop_revision)
715
def update_refs(old_refs):
716
refs = dict(old_refs)
717
# FIXME: Check for diverged branches
718
refs.update(new_refs)
720
result.revidmap, old_refs, new_refs = self.interrepo.dfetch_refs(
722
result.old_revid = old_refs.get(self.target.ref, (None, NULL_REVISION))[1]
723
result.new_revid = new_refs[main_ref][1]
727
branch.InterBranch.register_optimiser(InterGitRemoteLocalBranch)
1389
with self.source.lock_read(), self.target.lock_write():
1390
new_refs, main_ref, stop_revinfo = self._get_new_refs(
1391
stop_revision, stop_revno=_stop_revno)
1393
def update_refs(old_refs):
1394
return self._update_refs(result, old_refs, new_refs, overwrite)
1396
result.revidmap, old_refs, new_refs = (
1397
self.interrepo.fetch_refs(update_refs, lossy=False))
1398
except NoPushSupport:
1399
raise errors.NoRoundtrippingSupport(self.source, self.target)
1400
(old_sha1, result.old_revid) = old_refs.get(
1401
main_ref, (ZERO_SHA, NULL_REVISION))
1402
if result.old_revid is None:
1403
result.old_revid = self.target.lookup_foreign_revision_id(
1405
result.new_revid = new_refs[main_ref][1]
1406
result.local_branch = None
1407
result.master_branch = self.target
1409
for hook in branch.Branch.hooks['post_pull']:
1413
def push(self, overwrite=False, stop_revision=None, lossy=False,
1414
_override_hook_source_branch=None, _stop_revno=None):
1415
result = GitBranchPushResult()
1416
result.source_branch = self.source
1417
result.target_branch = self.target
1418
result.local_branch = None
1419
result.master_branch = result.target_branch
1420
with self.source.lock_read(), self.target.lock_write():
1421
new_refs, main_ref, stop_revinfo = self._get_new_refs(
1422
stop_revision, stop_revno=_stop_revno)
1424
def update_refs(old_refs):
1425
return self._update_refs(result, old_refs, new_refs, overwrite)
1427
result.revidmap, old_refs, new_refs = (
1428
self.interrepo.fetch_refs(
1429
update_refs, lossy=lossy, overwrite=overwrite))
1430
except NoPushSupport:
1431
raise errors.NoRoundtrippingSupport(self.source, self.target)
1432
(old_sha1, result.old_revid) = old_refs.get(
1433
main_ref, (ZERO_SHA, NULL_REVISION))
1434
if lossy or result.old_revid is None:
1435
result.old_revid = self.target.lookup_foreign_revision_id(
1437
result.new_revid = new_refs[main_ref][1]
1438
(result.new_original_revno,
1439
result.new_original_revid) = stop_revinfo
1440
for hook in branch.Branch.hooks['post_push']:
1445
branch.InterBranch.register_optimiser(InterGitLocalGitBranch)
728
1446
branch.InterBranch.register_optimiser(InterFromGitBranch)
729
1447
branch.InterBranch.register_optimiser(InterToGitBranch)
730
branch.InterBranch.register_optimiser(InterGitLocalRemoteBranch)
1448
branch.InterBranch.register_optimiser(InterLocalGitRemoteGitBranch)