1439
1439
last_rev, other_branch))
1441
1441
@needs_write_lock
1442
def update_revisions(self, other, stop_revision=None):
1442
def update_revisions(self, other, stop_revision=None, overwrite=False):
1443
1443
"""See Branch.update_revisions."""
1444
1444
other.lock_read()
1446
other_last_revno, other_last_revision = other.last_revision_info()
1446
1447
if stop_revision is None:
1447
stop_revision = other.last_revision()
1448
if stop_revision is None:
1448
stop_revision = other_last_revision
1449
if _mod_revision.is_null(stop_revision):
1449
1450
# if there are no commits, we're done.
1451
1452
# whats the current last revision, before we fetch [and change it
1456
1457
# already merged can operate on the just fetched graph, which will
1457
1458
# be cached in memory.
1458
1459
self.fetch(other, stop_revision)
1459
if self.repository.get_graph().is_ancestor(stop_revision,
1462
self.generate_revision_history(stop_revision, last_rev=last_rev,
1460
# Check to see if one is an ancestor of the other
1462
heads = self.repository.get_graph().heads([stop_revision,
1464
if heads == set([last_rev]):
1465
# The current revision is a decendent of the target,
1468
elif heads == set([stop_revision, last_rev]):
1469
# These branches have diverged
1470
raise errors.DivergedBranches(self, other)
1471
assert heads == set([stop_revision])
1472
if other_last_revision == stop_revision:
1473
self.set_last_revision_info(other_last_revno,
1474
other_last_revision)
1476
# TODO: jam 2007-11-29 Is there a way to determine the
1477
# revno without searching all of history??
1479
self.generate_revision_history(stop_revision)
1481
self.generate_revision_history(stop_revision,
1482
last_rev=last_rev, other_branch=other)
1485
1504
source.lock_read()
1487
1506
result.old_revno, result.old_revid = self.last_revision_info()
1489
self.update_revisions(source, stop_revision)
1490
except DivergedBranches:
1494
if stop_revision is None:
1495
stop_revision = source.last_revision()
1496
self.generate_revision_history(stop_revision)
1507
self.update_revisions(source, stop_revision, overwrite=overwrite)
1497
1508
result.tag_conflicts = source.tags.merge_to(self.tags, overwrite)
1498
1509
result.new_revno, result.new_revid = self.last_revision_info()
1499
1510
if _hook_master: