/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

merge bzr.dev

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."""
868
868
        """
869
869
        return None
870
870
 
 
871
    @classmethod
 
872
    def set_reference(self, a_bzrdir, to_branch):
 
873
        """Set the target reference of the branch in a_bzrdir.
 
874
 
 
875
        format probing must have been completed before calling
 
876
        this method - it is assumed that the format of the branch
 
877
        in a_bzrdir is correct.
 
878
 
 
879
        :param a_bzrdir: The bzrdir to set the branch reference for.
 
880
        :param to_branch: branch that the checkout is to reference
 
881
        """
 
882
        raise NotImplementedError(self.set_reference)
 
883
 
871
884
    def get_format_string(self):
872
885
        """Return the ASCII format string that identifies this format."""
873
886
        raise NotImplementedError(self.get_format_string)
1198
1211
        transport = a_bzrdir.get_branch_transport(None)
1199
1212
        return transport.get('location').read()
1200
1213
 
 
1214
    def set_reference(self, a_bzrdir, to_branch):
 
1215
        """See BranchFormat.set_reference()."""
 
1216
        transport = a_bzrdir.get_branch_transport(None)
 
1217
        location = transport.put_bytes('location', to_branch.base)
 
1218
 
1201
1219
    def initialize(self, a_bzrdir, target_branch=None):
1202
1220
        """Create a branch of this format in a_bzrdir."""
1203
1221
        if target_branch is None:
1439
1457
            last_rev, other_branch))
1440
1458
 
1441
1459
    @needs_write_lock
1442
 
    def update_revisions(self, other, stop_revision=None):
 
1460
    def update_revisions(self, other, stop_revision=None, overwrite=False):
1443
1461
        """See Branch.update_revisions."""
1444
1462
        other.lock_read()
1445
1463
        try:
 
1464
            other_last_revno, other_last_revision = other.last_revision_info()
1446
1465
            if stop_revision is None:
1447
 
                stop_revision = other.last_revision()
1448
 
                if stop_revision is None:
 
1466
                stop_revision = other_last_revision
 
1467
                if _mod_revision.is_null(stop_revision):
1449
1468
                    # if there are no commits, we're done.
1450
1469
                    return
1451
1470
            # whats the current last revision, before we fetch [and change it
1456
1475
            # already merged can operate on the just fetched graph, which will
1457
1476
            # be cached in memory.
1458
1477
            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)
 
1478
            # Check to see if one is an ancestor of the other
 
1479
            if not overwrite:
 
1480
                heads = self.repository.get_graph().heads([stop_revision,
 
1481
                                                           last_rev])
 
1482
                if heads == set([last_rev]):
 
1483
                    # The current revision is a decendent of the target,
 
1484
                    # nothing to do
 
1485
                    return
 
1486
                elif heads == set([stop_revision, last_rev]):
 
1487
                    # These branches have diverged
 
1488
                    raise errors.DivergedBranches(self, other)
 
1489
                assert heads == set([stop_revision])
 
1490
            if other_last_revision == stop_revision:
 
1491
                self.set_last_revision_info(other_last_revno,
 
1492
                                            other_last_revision)
 
1493
            else:
 
1494
                # TODO: jam 2007-11-29 Is there a way to determine the
 
1495
                #       revno without searching all of history??
 
1496
                if overwrite:
 
1497
                    self.generate_revision_history(stop_revision)
 
1498
                else:
 
1499
                    self.generate_revision_history(stop_revision,
 
1500
                        last_rev=last_rev, other_branch=other)
1464
1501
        finally:
1465
1502
            other.unlock()
1466
1503
 
1485
1522
        source.lock_read()
1486
1523
        try:
1487
1524
            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)
 
1525
            self.update_revisions(source, stop_revision, overwrite=overwrite)
1497
1526
            result.tag_conflicts = source.tags.merge_to(self.tags, overwrite)
1498
1527
            result.new_revno, result.new_revid = self.last_revision_info()
1499
1528
            if _hook_master:
1849
1878
        return None
1850
1879
 
1851
1880
    @classmethod
 
1881
    def set_reference(self, a_bzrdir, to_branch):
 
1882
        """Set the target reference of the branch in a_bzrdir.
 
1883
 
 
1884
        format probing must have been completed before calling
 
1885
        this method - it is assumed that the format of the branch
 
1886
        in a_bzrdir is correct.
 
1887
 
 
1888
        :param a_bzrdir: The bzrdir to set the branch reference for.
 
1889
        :param to_branch: branch that the checkout is to reference
 
1890
        """
 
1891
        raise NotImplementedError(self.set_reference)
 
1892
 
 
1893
    @classmethod
1852
1894
    def _initialize_control_files(cls, a_bzrdir, utf8_files, lock_filename,
1853
1895
            lock_class):
1854
1896
        branch_transport = a_bzrdir.get_branch_transport(cls)