~bzr-pqm/bzr/bzr.dev

« 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:
28
28
import bzrlib.bzrdir as bzrdir
29
29
from bzrlib.config import TreeConfig
30
30
from bzrlib.decorators import needs_read_lock, needs_write_lock
31
 
from bzrlib.delta import compare_trees
32
31
import bzrlib.errors as errors
33
 
from bzrlib.errors import (BzrError, InvalidRevisionNumber, InvalidRevisionId,
34
 
                           NoSuchRevision, HistoryMissing, NotBranchError,
35
 
                           DivergedBranches, LockError,
36
 
                           UninitializableFormat,
37
 
                           UnlistableStore,
38
 
                           UnlistableBranch, NoSuchFile, NotVersionedError,
39
 
                           NoWorkingTree)
 
32
from bzrlib.errors import (BzrError, BzrCheckError, DivergedBranches, 
 
33
                           HistoryMissing, InvalidRevisionId, 
 
34
                           InvalidRevisionNumber, LockError, NoSuchFile, 
 
35
                           NoSuchRevision, NoWorkingTree, NotVersionedError,
 
36
                           NotBranchError, UninitializableFormat, 
 
37
                           UnlistableStore, UnlistableBranch, 
 
38
                           )
40
39
import bzrlib.inventory as inventory
41
40
from bzrlib.inventory import Inventory
42
41
from bzrlib.lockable_files import LockableFiles, TransportLock
59
58
from bzrlib.trace import mutter, note
60
59
import bzrlib.transactions as transactions
61
60
from bzrlib.transport import Transport, get_transport
62
 
from bzrlib.tree import EmptyTree, RevisionTree
63
61
import bzrlib.ui
64
62
import bzrlib.urlutils as urlutils
65
63
import bzrlib.xml5
277
275
        """
278
276
        return None
279
277
 
 
278
    def get_revision_delta(self, revno):
 
279
        """Return the delta for one revision.
 
280
 
 
281
        The delta is relative to its mainline predecessor, or the
 
282
        empty tree for revision 1.
 
283
        """
 
284
        assert isinstance(revno, int)
 
285
        rh = self.revision_history()
 
286
        if not (1 <= revno <= len(rh)):
 
287
            raise InvalidRevisionNumber(revno)
 
288
        return self.repository.get_revision_delta(rh[revno-1])
 
289
 
280
290
    def get_root_id(self):
281
291
        """Return the id of this branches root"""
282
292
        raise NotImplementedError('get_root_id is abstract')
332
342
        >>> br1.missing_revisions(br2)
333
343
        []
334
344
        >>> wt2.commit("lala!", rev_id="REVISION-ID-1")
 
345
        'REVISION-ID-1'
335
346
        >>> br1.missing_revisions(br2)
336
347
        [u'REVISION-ID-1']
337
348
        >>> br2.missing_revisions(br1)
338
349
        []
339
350
        >>> wt1.commit("lala!", rev_id="REVISION-ID-1")
 
351
        'REVISION-ID-1'
340
352
        >>> br1.missing_revisions(br2)
341
353
        []
342
354
        >>> wt2.commit("lala!", rev_id="REVISION-ID-2A")
 
355
        'REVISION-ID-2A'
343
356
        >>> br1.missing_revisions(br2)
344
357
        [u'REVISION-ID-2A']
345
358
        >>> wt1.commit("lala!", rev_id="REVISION-ID-2B")
 
359
        'REVISION-ID-2B'
346
360
        >>> br1.missing_revisions(br2)
347
361
        Traceback (most recent call last):
348
362
        DivergedBranches: These branches have diverged.  Try merge.
1069
1083
            # not really an object yet, and the transaction is for objects.
1070
1084
            # transaction.register_clean(history)
1071
1085
 
1072
 
    def get_revision_delta(self, revno):
1073
 
        """Return the delta for one revision.
1074
 
 
1075
 
        The delta is relative to its mainline predecessor, or the
1076
 
        empty tree for revision 1.
1077
 
        """
1078
 
        assert isinstance(revno, int)
1079
 
        rh = self.revision_history()
1080
 
        if not (1 <= revno <= len(rh)):
1081
 
            raise InvalidRevisionNumber(revno)
1082
 
 
1083
 
        # revno is 1-based; list is 0-based
1084
 
 
1085
 
        new_tree = self.repository.revision_tree(rh[revno-1])
1086
 
        if revno == 1:
1087
 
            old_tree = EmptyTree()
1088
 
        else:
1089
 
            old_tree = self.repository.revision_tree(rh[revno-2])
1090
 
        return compare_trees(old_tree, new_tree)
1091
 
 
1092
1086
    @needs_read_lock
1093
1087
    def revision_history(self):
1094
1088
        """See Branch.revision_history."""
1184
1178
        assert self.base[-1] == '/'
1185
1179
        for l in _locs:
1186
1180
            try:
1187
 
                return urlutils.join(self.base[:-1], 
1188
 
                            self.control_files.get(l).read().strip('\n'))
 
1181
                parent = self.control_files.get(l).read().strip('\n')
1189
1182
            except NoSuchFile:
1190
 
                pass
 
1183
                continue
 
1184
            # This is an old-format absolute path to a local branch
 
1185
            # turn it into a url
 
1186
            if parent.startswith('/'):
 
1187
                parent = urlutils.local_path_to_url(parent.decode('utf8'))
 
1188
            return urlutils.join(self.base[:-1], parent)
1191
1189
        return None
1192
1190
 
1193
1191
    def get_push_location(self):