426
426
return (0, _mod_revision.NULL_REVISION)
428
@deprecated_method(deprecated_in((1, 6, 0)))
428
429
def missing_revisions(self, other, stop_revision=None):
429
430
"""Return a list of new revisions that would perfectly fit.
447
448
raise errors.NoSuchRevision(self, stop_revision)
448
449
return other_history[self_len:stop_revision]
450
452
def update_revisions(self, other, stop_revision=None, overwrite=False,
452
454
"""Pull in new perfect-fit revisions.
459
461
information. This can be None.
462
raise NotImplementedError(self.update_revisions)
466
other_revno, other_last_revision = other.last_revision_info()
467
stop_revno = None # unknown
468
if stop_revision is None:
469
stop_revision = other_last_revision
470
if _mod_revision.is_null(stop_revision):
471
# if there are no commits, we're done.
473
stop_revno = other_revno
475
# what's the current last revision, before we fetch [and change it
477
last_rev = _mod_revision.ensure_null(self.last_revision())
478
# we fetch here so that we don't process data twice in the common
479
# case of having something to pull, and so that the check for
480
# already merged can operate on the just fetched graph, which will
481
# be cached in memory.
482
self.fetch(other, stop_revision)
483
# Check to see if one is an ancestor of the other
486
graph = self.repository.get_graph()
487
heads = graph.heads([stop_revision, last_rev])
488
if heads == set([last_rev]):
489
# The current revision is a decendent of the target,
492
elif heads == set([stop_revision, last_rev]):
493
# These branches have diverged
494
raise errors.DivergedBranches(self, other)
495
elif heads != set([stop_revision]):
496
raise AssertionError("invalid heads: %r" % heads)
497
if stop_revno is None:
499
graph = self.repository.get_graph()
500
this_revno, this_last_revision = self.last_revision_info()
501
stop_revno = graph.find_distance_to_null(stop_revision,
502
[(other_last_revision, other_revno),
503
(this_last_revision, this_revno)])
504
self.set_last_revision_info(stop_revno, stop_revision)
464
510
def revision_id_to_revno(self, revision_id):
465
511
"""Given a revision id, return its revno"""
918
964
for (filename, content) in utf8_files:
919
965
branch_transport.put_bytes(
920
966
filename, content,
921
mode=control_files._file_mode)
967
mode=a_bzrdir._get_file_mode())
923
969
control_files.unlock()
924
970
return self.open(a_bzrdir, _found=True)
1412
1458
It is intended to be called by BzrBranch5.set_revision_history."""
1413
1459
self._transport.put_bytes(
1414
1460
'revision-history', '\n'.join(history),
1415
mode=self.control_files._file_mode)
1461
mode=self.bzrdir._get_file_mode())
1417
1463
@needs_write_lock
1418
1464
def set_revision_history(self, rev_history):
1505
1551
self.set_revision_history(self._lefthand_history(revision_id,
1506
1552
last_rev, other_branch))
1509
def update_revisions(self, other, stop_revision=None, overwrite=False,
1511
"""See Branch.update_revisions."""
1514
other_revno, other_last_revision = other.last_revision_info()
1515
stop_revno = None # unknown
1516
if stop_revision is None:
1517
stop_revision = other_last_revision
1518
if _mod_revision.is_null(stop_revision):
1519
# if there are no commits, we're done.
1521
stop_revno = other_revno
1523
# what's the current last revision, before we fetch [and change it
1525
last_rev = _mod_revision.ensure_null(self.last_revision())
1526
# we fetch here so that we don't process data twice in the common
1527
# case of having something to pull, and so that the check for
1528
# already merged can operate on the just fetched graph, which will
1529
# be cached in memory.
1530
self.fetch(other, stop_revision)
1531
# Check to see if one is an ancestor of the other
1534
graph = self.repository.get_graph()
1535
heads = graph.heads([stop_revision, last_rev])
1536
if heads == set([last_rev]):
1537
# The current revision is a decendent of the target,
1540
elif heads == set([stop_revision, last_rev]):
1541
# These branches have diverged
1542
raise errors.DivergedBranches(self, other)
1543
elif heads != set([stop_revision]):
1544
raise AssertionError("invalid heads: %r" % heads)
1545
if stop_revno is None:
1547
graph = self.repository.get_graph()
1548
this_revno, this_last_revision = self.last_revision_info()
1549
stop_revno = graph.find_distance_to_null(stop_revision,
1550
[(other_last_revision, other_revno),
1551
(this_last_revision, this_revno)])
1552
self.set_last_revision_info(stop_revno, stop_revision)
1556
1554
def basis_tree(self):
1557
1555
"""See Branch.basis_tree."""
1558
1556
return self.repository.revision_tree(self.last_revision())
1734
1732
self._transport.delete('parent')
1736
1734
self._transport.put_bytes('parent', url + '\n',
1737
mode=self.control_files._file_mode)
1735
mode=self.bzrdir._get_file_mode())
1740
1738
class BzrBranch5(BzrBranch):
1913
1911
revision_id = _mod_revision.ensure_null(revision_id)
1914
1912
out_string = '%d %s\n' % (revno, revision_id)
1915
1913
self._transport.put_bytes('last-revision', out_string,
1916
mode=self.control_files._file_mode)
1914
mode=self.bzrdir._get_file_mode())
1918
1916
@needs_write_lock
1919
1917
def set_last_revision_info(self, revno, revision_id):
2224
2222
# Copying done; now update target format
2225
2223
new_branch._transport.put_bytes('format',
2226
2224
format.get_format_string(),
2227
mode=new_branch.control_files._file_mode)
2225
mode=new_branch.bzrdir._get_file_mode())
2229
2227
# Clean up old files
2230
2228
new_branch._transport.delete('revision-history')