~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-10-04 11:13:33 UTC
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1403.
  • Revision ID: mbp@sourcefrog.net-20051004111332-f7b8a6bd41b9fe22
- tweak capture_tree formatting

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
157
156
        """Subclasses that care about caching should override this, and set
158
157
        up cached stores located under cache_root.
159
158
        """
160
 
        self.cache_root = cache_root
161
159
 
162
160
 
163
161
class _Branch(Branch):
239
237
        self._check_format(relax_version_check)
240
238
 
241
239
        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
240
            relpath = self._rel_controlfilename(name)
247
241
            if compressed:
248
242
                store = CompressedTextStore(self._transport.clone(relpath))
249
243
            else:
250
244
                store = TextStore(self._transport.clone(relpath))
251
 
            #if self._transport.should_cache():
252
 
            #    cache_path = os.path.join(self.cache_root, name)
253
 
            #    os.mkdir(cache_path)
254
 
            #    store = bzrlib.store.CachedStore(store, cache_path)
 
245
            if self._transport.should_cache():
 
246
                from meta_store import CachedStore
 
247
                cache_path = os.path.join(self.cache_root, name)
 
248
                os.mkdir(cache_path)
 
249
                store = CachedStore(store, cache_path)
255
250
            return store
256
251
        def get_weave(name):
257
252
            relpath = self._rel_controlfilename(name)
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: