/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: Martin Pool
  • Date: 2007-10-10 00:21:57 UTC
  • mfrom: (2900 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071010002157-utci0x44m2w47wgd
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        bzrdir,
27
27
        cache_utf8,
28
28
        config as _mod_config,
 
29
        debug,
29
30
        errors,
30
31
        lockdir,
31
32
        lockable_files,
61
62
                                      zero_eight, zero_nine, zero_sixteen,
62
63
                                      zero_ninetyone,
63
64
                                      )
64
 
from bzrlib.trace import mutter, note
 
65
from bzrlib.trace import mutter, mutter_callsite, note
65
66
 
66
67
 
67
68
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
404
405
 
405
406
    @needs_read_lock
406
407
    def revision_history(self):
407
 
        """Return sequence of revision hashes on to this branch.
 
408
        """Return sequence of revision ids on this branch.
408
409
        
409
410
        This method will cache the revision history for as long as it is safe to
410
411
        do so.
411
412
        """
 
413
        if 'evil' in debug.debug_flags:
 
414
            mutter_callsite(3, "revision_history scales with history.")
412
415
        if self._revision_history_cache is not None:
413
416
            history = self._revision_history_cache
414
417
        else:
488
491
        """Given a revision id, return its revno"""
489
492
        if _mod_revision.is_null(revision_id):
490
493
            return 0
491
 
        revision_id = osutils.safe_revision_id(revision_id)
492
494
        history = self.revision_history()
493
495
        try:
494
496
            return history.index(revision_id) + 1
505
507
            raise errors.NoSuchRevision(self, revno)
506
508
        return history[revno - 1]
507
509
 
508
 
    def pull(self, source, overwrite=False, stop_revision=None):
 
510
    def pull(self, source, overwrite=False, stop_revision=None,
 
511
             possible_transports=None):
509
512
        """Mirror source into this branch.
510
513
 
511
514
        This branch is considered to be 'local', having low latency.
686
689
            new_history = []
687
690
        new_history = self.revision_history()
688
691
        if revision_id is not None and new_history != []:
689
 
            revision_id = osutils.safe_revision_id(revision_id)
690
692
            try:
691
693
                new_history = new_history[:new_history.index(revision_id) + 1]
692
694
            except ValueError:
1363
1365
    @needs_write_lock
1364
1366
    def set_revision_history(self, rev_history):
1365
1367
        """See Branch.set_revision_history."""
1366
 
        rev_history = [osutils.safe_revision_id(r) for r in rev_history]
 
1368
        if 'evil' in debug.debug_flags:
 
1369
            mutter_callsite(3, "set_revision_history scales with history.")
1367
1370
        self._clear_cached_state()
1368
1371
        self._write_revision_history(rev_history)
1369
1372
        self._cache_revision_history(rev_history)
1382
1385
        configured to check constraints on history, in which case this may not
1383
1386
        be permitted.
1384
1387
        """
1385
 
        revision_id = osutils.safe_revision_id(revision_id)
1386
1388
        history = self._lefthand_history(revision_id)
1387
1389
        assert len(history) == revno, '%d != %d' % (len(history), revno)
1388
1390
        self.set_revision_history(history)
1396
1398
 
1397
1399
    def _lefthand_history(self, revision_id, last_rev=None,
1398
1400
                          other_branch=None):
 
1401
        if 'evil' in debug.debug_flags:
 
1402
            mutter_callsite(4, "_lefthand_history scales with history.")
1399
1403
        # stop_revision must be a descendant of last_revision
1400
1404
        stop_graph = self.repository.get_revision_graph(revision_id)
1401
1405
        if (last_rev is not None and last_rev != _mod_revision.NULL_REVISION
1426
1430
        :param other_branch: The other branch that DivergedBranches should
1427
1431
            raise with respect to.
1428
1432
        """
1429
 
        revision_id = osutils.safe_revision_id(revision_id)
1430
1433
        self.set_revision_history(self._lefthand_history(revision_id,
1431
1434
            last_rev, other_branch))
1432
1435
 
1440
1443
                if stop_revision is None:
1441
1444
                    # if there are no commits, we're done.
1442
1445
                    return
1443
 
            else:
1444
 
                stop_revision = osutils.safe_revision_id(stop_revision)
1445
1446
            # whats the current last revision, before we fetch [and change it
1446
1447
            # possibly]
1447
1448
            last_rev = _mod_revision.ensure_null(self.last_revision())
1448
 
            # we fetch here regardless of whether we need to so that we pickup
1449
 
            # filled in ghosts.
 
1449
            # we fetch here so that we don't process data twice in the common
 
1450
            # case of having something to pull, and so that the check for 
 
1451
            # already merged can operate on the just fetched graph, which will
 
1452
            # be cached in memory.
1450
1453
            self.fetch(other, stop_revision)
1451
1454
            if self.repository.get_graph().is_ancestor(stop_revision,
1452
1455
                                                       last_rev):
1462
1465
 
1463
1466
    @needs_write_lock
1464
1467
    def pull(self, source, overwrite=False, stop_revision=None,
1465
 
             _hook_master=None, run_hooks=True):
 
1468
             _hook_master=None, run_hooks=True, possible_transports=None):
1466
1469
        """See Branch.pull.
1467
1470
 
1468
1471
        :param _hook_master: Private parameter - set the branch to 
1666
1669
        
1667
1670
    @needs_write_lock
1668
1671
    def pull(self, source, overwrite=False, stop_revision=None,
1669
 
             run_hooks=True):
 
1672
             run_hooks=True, possible_transports=None):
1670
1673
        """Pull from source into self, updating my master if any.
1671
1674
        
1672
1675
        :param run_hooks: Private parameter - if false, this branch
1677
1680
        master_branch = None
1678
1681
        if bound_location and source.base != bound_location:
1679
1682
            # not pulling from master, so we need to update master.
1680
 
            master_branch = self.get_master_branch()
 
1683
            master_branch = self.get_master_branch(possible_transports)
1681
1684
            master_branch.lock_write()
1682
1685
        try:
1683
1686
            if master_branch:
1930
1933
 
1931
1934
    @needs_write_lock
1932
1935
    def set_last_revision_info(self, revno, revision_id):
1933
 
        revision_id = osutils.safe_revision_id(revision_id)
1934
1936
        if self._get_append_revisions_only():
1935
1937
            self._check_history_violation(revision_id)
1936
1938
        self._write_last_revision_info(revno, revision_id)