~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-04 04:38:48 UTC
  • mfrom: (1400.1.1)
  • Revision ID: robertc@robertcollins.net-20051004043848-d65bb5f9d435fbb3
unbreak http branch operations

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
239
238
        self._check_format(relax_version_check)
240
239
 
241
240
        def get_store(name, compressed=True):
242
 
            # FIXME: This approach of assuming stores are all entirely compressed
243
 
            # or entirely uncompressed is tidy, but breaks upgrade from 
244
 
            # some existing branches where there's a mixture; we probably 
245
 
            # still want the option to look for both.
246
241
            relpath = self._rel_controlfilename(name)
247
242
            if compressed:
248
243
                store = CompressedTextStore(self._transport.clone(relpath))
466
461
            fmt = self.controlfile('branch-format', 'r').read()
467
462
        except NoSuchFile:
468
463
            raise NotBranchError(self.base)
469
 
        mutter("got branch format %r", fmt)
 
464
 
470
465
        if fmt == BZR_BRANCH_FORMAT_5:
471
466
            self._branch_format = 5
472
467
        elif fmt == BZR_BRANCH_FORMAT_4:
781
776
        # But for now, just hash the contents.
782
777
        return bzrlib.osutils.sha_file(self.get_revision_xml_file(revision_id))
783
778
 
 
779
    def _get_ancestry_weave(self):
 
780
        return self.control_weaves.get_weave('ancestry')
 
781
 
784
782
    def get_ancestry(self, revision_id):
785
783
        """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
784
        """
 
785
        # strip newlines
790
786
        if revision_id is None:
791
787
            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)]))
 
788
        w = self._get_ancestry_weave()
 
789
        return [None] + [l[:-1] for l in w.get_iter(w.lookup(revision_id))]
795
790
 
796
791
    def get_inventory_weave(self):
797
792
        return self.control_weaves.get_weave('inventory')
1201
1196
    def add_pending_merge(self, *revision_ids):
1202
1197
        # TODO: Perhaps should check at this point that the
1203
1198
        # history of the revision is actually present?
 
1199
        for rev_id in revision_ids:
 
1200
            validate_revision_id(rev_id)
 
1201
 
1204
1202
        p = self.pending_merges()
1205
1203
        updated = False
1206
1204
        for rev_id in revision_ids: