/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-04 18:11:51 UTC
  • mfrom: (3074 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3075.
  • Revision ID: john@arbash-meinel.com-20071204181151-br85qwsgshso16q5
[merge] bzr.dev 3074

Show diffs side-by-side

added added

removed removed

Lines of Context:
425
425
        That is equivalent to the number of revisions committed to
426
426
        this branch.
427
427
        """
428
 
        return len(self.revision_history())
 
428
        return self.last_revision_info()[0]
429
429
 
430
430
    def unbind(self):
431
431
        """Older format branches cannot bind or unbind."""
1439
1439
            last_rev, other_branch))
1440
1440
 
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()
1445
1445
        try:
 
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.
1450
1451
                    return
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,
1460
 
                                                       last_rev):
1461
 
                return
1462
 
            self.generate_revision_history(stop_revision, last_rev=last_rev,
1463
 
                other_branch=other)
 
1460
            # Check to see if one is an ancestor of the other
 
1461
            if not overwrite:
 
1462
                heads = self.repository.get_graph().heads([stop_revision,
 
1463
                                                           last_rev])
 
1464
                if heads == set([last_rev]):
 
1465
                    # The current revision is a decendent of the target,
 
1466
                    # nothing to do
 
1467
                    return
 
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)
 
1475
            else:
 
1476
                # TODO: jam 2007-11-29 Is there a way to determine the
 
1477
                #       revno without searching all of history??
 
1478
                if overwrite:
 
1479
                    self.generate_revision_history(stop_revision)
 
1480
                else:
 
1481
                    self.generate_revision_history(stop_revision,
 
1482
                        last_rev=last_rev, other_branch=other)
1464
1483
        finally:
1465
1484
            other.unlock()
1466
1485
 
1485
1504
        source.lock_read()
1486
1505
        try:
1487
1506
            result.old_revno, result.old_revid = self.last_revision_info()
1488
 
            try:
1489
 
                self.update_revisions(source, stop_revision)
1490
 
            except DivergedBranches:
1491
 
                if not overwrite:
1492
 
                    raise
1493
 
            if overwrite:
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: