~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Merge from aaron. Whee, we are synced. Yay. Begone the foul demons of merge conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
 
19
 
from bzrlib.lockablefiles import LockableFiles
 
19
from bzrlib.lockable_files import LockableFiles
20
20
from bzrlib.tree import EmptyTree
21
21
from bzrlib.revision import NULL_REVISION
 
22
from bzrlib.store import copy_all
22
23
from bzrlib.store.weave import WeaveStore
23
24
from bzrlib.store.text import TextStore
24
25
import bzrlib.xml5
48
49
            self.control_files.unlock()
49
50
    return decorated
50
51
 
51
 
class RevisionStorage(object):
 
52
 
 
53
class Repository(object):
52
54
    def __init__(self, transport, branch_format):
53
55
        object.__init__(self)
54
56
        self.control_files = LockableFiles(transport, 'storage-lock')
66
68
            # some existing branches where there's a mixture; we probably 
67
69
            # still want the option to look for both.
68
70
            relpath = self.control_files._rel_controlfilename(name)
69
 
            if compressed:
70
 
                store = TextStore(
71
 
                    self.control_files.make_transport(relpath),
72
 
                    prefixed=prefixed)
73
 
            else:
74
 
                store = TextStore(self.control_files.make_transport(relpath),
75
 
                                  prefixed=prefixed)
 
71
            store = TextStore(self.control_files.make_transport(relpath),
 
72
                              prefixed=prefixed, compressed=compressed)
76
73
            #if self._transport.should_cache():
77
74
            #    cache_path = os.path.join(self.cache_root, name)
78
75
            #    os.mkdir(cache_path)
103
100
    def unlock(self):
104
101
        self.control_files.unlock()
105
102
 
 
103
    def copy(self, destination):
 
104
        destination.control_weaves.copy_multi(self.control_weaves, 
 
105
                ['inventory'])
 
106
        copy_all(self.weave_store, destination.weave_store)
 
107
        copy_all(self.revision_store, destination.revision_store)
 
108
 
106
109
    def has_revision(self, revision_id):
107
110
        """True if this branch has a copy of the revision.
108
111
 
204
207
            inv = self.get_revision_inventory(revision_id)
205
208
            return RevisionTree(self.weave_store, inv, revision_id)
206
209
 
 
210
    def get_ancestry(self, revision_id):
 
211
        """Return a list of revision-ids integrated by a revision.
 
212
        
 
213
        This is topologically sorted.
 
214
        """
 
215
        if revision_id is None:
 
216
            return [None]
 
217
        w = self.get_inventory_weave()
 
218
        return [None] + map(w.idx_to_name,
 
219
                            w.inclusions([w.lookup(revision_id)]))
 
220
 
207
221
    @needs_read_lock
208
222
    def print_file(self, file, revision_id):
209
223
        """Print `file` to stdout."""