~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
from bzrlib.errors import (BzrError, BzrCheckError, DivergedBranches,
50
50
                           HistoryMissing, InvalidRevisionId,
51
51
                           InvalidRevisionNumber, LockError, NoSuchFile,
52
 
                           NoSuchRevision, NoWorkingTree, NotVersionedError,
 
52
                           NoSuchRevision, NotVersionedError,
53
53
                           NotBranchError, UninitializableFormat,
54
54
                           UnlistableStore, UnlistableBranch,
55
55
                           )
117
117
            master.break_lock()
118
118
 
119
119
    @staticmethod
120
 
    @deprecated_method(zero_eight)
121
 
    def open_downlevel(base):
122
 
        """Open a branch which may be of an old format."""
123
 
        return Branch.open(base, _unsupported=True)
124
 
 
125
 
    @staticmethod
126
120
    def open(base, _unsupported=False):
127
121
        """Open the branch rooted at base.
128
122
 
154
148
                                                         possible_transports)
155
149
        return control.open_branch(), relpath
156
150
 
157
 
    @staticmethod
158
 
    @deprecated_function(zero_eight)
159
 
    def initialize(base):
160
 
        """Create a new working tree and branch, rooted at 'base' (url)
161
 
 
162
 
        NOTE: This will soon be deprecated in favour of creation
163
 
        through a BzrDir.
164
 
        """
165
 
        return bzrdir.BzrDir.create_standalone_workingtree(base).branch
166
 
 
167
 
    @deprecated_function(zero_eight)
168
 
    def setup_caching(self, cache_root):
169
 
        """Subclasses that care about caching should override this, and set
170
 
        up cached stores located under cache_root.
171
 
        
172
 
        NOTE: This is unused.
173
 
        """
174
 
        pass
175
 
 
176
151
    def get_config(self):
177
152
        return BranchConfig(self)
178
153
 
377
352
        """Print `file` to stdout."""
378
353
        raise NotImplementedError(self.print_file)
379
354
 
380
 
    @deprecated_method(zero_ninetyone)
381
 
    def append_revision(self, *revision_ids):
382
 
        """Append the specified revisions to the branch's revision history.
383
 
 
384
 
        Rather than calling this, please use set_last_revision_info(), which
385
 
        takes just the new tip revision.
386
 
        """
387
 
        raise NotImplementedError(self.append_revision)
388
 
 
389
355
    def set_revision_history(self, rev_history):
390
356
        raise NotImplementedError(self.set_revision_history)
391
357
 
1375
1341
        """See Branch.print_file."""
1376
1342
        return self.repository.print_file(file, revision_id)
1377
1343
 
1378
 
    @deprecated_method(zero_ninetyone)
1379
 
    @needs_write_lock
1380
 
    def append_revision(self, *revision_ids):
1381
 
        """See Branch.append_revision."""
1382
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
1383
 
        for revision_id in revision_ids:
1384
 
            _mod_revision.check_not_reserved_id(revision_id)
1385
 
            mutter("add {%s} to revision-history" % revision_id)
1386
 
        rev_history = self.revision_history()
1387
 
        rev_history.extend(revision_ids)
1388
 
        self.set_revision_history(rev_history)
1389
 
 
1390
1344
    def _write_revision_history(self, history):
1391
1345
        """Factored out of set_revision_history.
1392
1346
 
1407
1361
 
1408
1362
    @needs_write_lock
1409
1363
    def set_last_revision_info(self, revno, revision_id):
 
1364
        """Set the last revision of this branch.
 
1365
 
 
1366
        The caller is responsible for checking that the revno is correct
 
1367
        for this revision id.
 
1368
 
 
1369
        It may be possible to set the branch last revision to an id not
 
1370
        present in the repository.  However, branches can also be 
 
1371
        configured to check constraints on history, in which case this may not
 
1372
        be permitted.
 
1373
        """
1410
1374
        revision_id = osutils.safe_revision_id(revision_id)
1411
1375
        history = self._lefthand_history(revision_id)
1412
1376
        assert len(history) == revno, '%d != %d' % (len(history), revno)
1485
1449
        """See Branch.basis_tree."""
1486
1450
        return self.repository.revision_tree(self.last_revision())
1487
1451
 
1488
 
    @deprecated_method(zero_eight)
1489
 
    def working_tree(self):
1490
 
        """Create a Working tree object for this branch."""
1491
 
 
1492
 
        from bzrlib.transport.local import LocalTransport
1493
 
        if (self.base.find('://') != -1 or 
1494
 
            not isinstance(self._transport, LocalTransport)):
1495
 
            raise NoWorkingTree(self.base)
1496
 
        return self.bzrdir.open_workingtree()
1497
 
 
1498
1452
    @needs_write_lock
1499
1453
    def pull(self, source, overwrite=False, stop_revision=None,
1500
1454
             _hook_master=None, run_hooks=True):
1682
1636
            assert isinstance(url, str)
1683
1637
            self.control_files.put_bytes('parent', url + '\n')
1684
1638
 
1685
 
    @deprecated_function(zero_nine)
1686
 
    def tree_config(self):
1687
 
        """DEPRECATED; call get_config instead.  
1688
 
        TreeConfig has become part of BranchConfig."""
1689
 
        return TreeConfig(self)
1690
 
 
1691
1639
 
1692
1640
class BzrBranch5(BzrBranch):
1693
1641
    """A format 5 branch. This supports new features over plan branches.
2009
1957
            self._check_history_violation(last_revision)
2010
1958
        self._write_last_revision_info(len(history), last_revision)
2011
1959
 
2012
 
    @deprecated_method(zero_ninetyone)
2013
 
    @needs_write_lock
2014
 
    def append_revision(self, *revision_ids):
2015
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
2016
 
        if len(revision_ids) == 0:
2017
 
            return
2018
 
        prev_revno, prev_revision = self.last_revision_info()
2019
 
        for revision in self.repository.get_revisions(revision_ids):
2020
 
            if prev_revision == _mod_revision.NULL_REVISION:
2021
 
                if revision.parent_ids != []:
2022
 
                    raise errors.NotLeftParentDescendant(self, prev_revision,
2023
 
                                                         revision.revision_id)
2024
 
            else:
2025
 
                if revision.parent_ids[0] != prev_revision:
2026
 
                    raise errors.NotLeftParentDescendant(self, prev_revision,
2027
 
                                                         revision.revision_id)
2028
 
            prev_revision = revision.revision_id
2029
 
        self.set_last_revision_info(prev_revno + len(revision_ids),
2030
 
                                    revision_ids[-1])
2031
 
 
2032
1960
    @needs_write_lock
2033
1961
    def _set_parent_location(self, url):
2034
1962
        """Set the parent branch"""