~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-06 00:52:53 UTC
  • Revision ID: robertc@robertcollins.net-20051006005253-415c38ad22094f13
define some expected behaviour for inventory_entry.snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                           DivergedBranches, LockError, UnlistableStore,
35
35
                           UnlistableBranch, NoSuchFile)
36
36
from bzrlib.textui import show_status
37
 
from bzrlib.revision import Revision
 
37
from bzrlib.revision import Revision, validate_revision_id, is_ancestor
38
38
from bzrlib.delta import compare_trees
39
39
from bzrlib.tree import EmptyTree, RevisionTree
40
40
from bzrlib.inventory import Inventory
134
134
    def open(base):
135
135
        """Open an existing branch, rooted at 'base' (url)"""
136
136
        t = get_transport(base)
137
 
        mutter("trying to open %r with transport %r", base, t)
138
137
        return _Branch(t)
139
138
 
140
139
    @staticmethod
466
465
            fmt = self.controlfile('branch-format', 'r').read()
467
466
        except NoSuchFile:
468
467
            raise NotBranchError(self.base)
469
 
        mutter("got branch format %r", fmt)
 
468
 
470
469
        if fmt == BZR_BRANCH_FORMAT_5:
471
470
            self._branch_format = 5
472
471
        elif fmt == BZR_BRANCH_FORMAT_4:
781
780
        # But for now, just hash the contents.
782
781
        return bzrlib.osutils.sha_file(self.get_revision_xml_file(revision_id))
783
782
 
 
783
    def _get_ancestry_weave(self):
 
784
        return self.control_weaves.get_weave('ancestry')
 
785
 
784
786
    def get_ancestry(self, revision_id):
785
787
        """Return a list of revision-ids integrated by a revision.
786
 
        
787
 
        This currently returns a list, but the ordering is not guaranteed:
788
 
        treat it as a set.
789
788
        """
 
789
        # strip newlines
790
790
        if revision_id is None:
791
791
            return [None]
792
 
        w = self.control_weaves.get_weave('inventory')
793
 
        return [None] + map(w.idx_to_name,
794
 
                            w.inclusions([w.lookup(revision_id)]))
 
792
        w = self._get_ancestry_weave()
 
793
        return [None] + [l[:-1] for l in w.get_iter(w.lookup(revision_id))]
795
794
 
796
795
    def get_inventory_weave(self):
797
796
        return self.control_weaves.get_weave('inventory')
1201
1200
    def add_pending_merge(self, *revision_ids):
1202
1201
        # TODO: Perhaps should check at this point that the
1203
1202
        # history of the revision is actually present?
 
1203
        for rev_id in revision_ids:
 
1204
            validate_revision_id(rev_id)
 
1205
 
1204
1206
        p = self.pending_merges()
1205
1207
        updated = False
1206
1208
        for rev_id in revision_ids: